package com.ymatou.iapi.productsync.testcase;
import com.google.common.collect.Lists;
import com.mongodb.BasicDBObject;
import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ModifyAgentProductBean;
import com.shop2cn.iapi.agentproducts.service.AddAgentProductCall;
import com.shop2cn.iapi.agentproducts.service.ImportAgentProductCall;
import com.ymatou.iapi.liveseller.parameter.CreateLiveActivityBean;
import com.ymatou.iapi.liveseller.parameter.CreateSellerLiveBean;
import com.ymatou.iapi.liveseller.parameter.ModifyLiveActivityBean;
import com.ymatou.iapi.liveseller.service.ModifyLiveActivityCall;
import com.ymatou.iapi.prodstock.parameter.AgentProductPo;
import com.ymatou.iapi.prodstock.parameter.AuditProductActivityStockBean;
import com.ymatou.iapi.productmanager.parameter.SaveGrouponBean;
import com.ymatou.iapi.productmanager.parameter.SaveProductTemplateBean;
import com.ymatou.iapi.productmanager.parameter.SetPspStatusBean;
import com.ymatou.iapi.productmanager.parameter.product.AddSellerProductRequest;
import com.ymatou.iapi.productmanager.parameter.product.ModifySellerProductRequest;
import com.ymatou.iapi.productmanager.service.ModifySellerProductCall;
import com.ymatou.iapi.productmanager.service.SaveProductTemplateCall;
import com.ymatou.iapi.productmanager.service.SetPspStatusCall;
import com.ymatou.iapi.productmanager.service.UpdateProductSensitiveWordCall;
import com.ymatou.iapi.productquery.parameter.GetProductInfoByProductIdBean;
import com.ymatou.iapi.productquery.service.GetProductInfoByProductIdCall;
import com.ymatou.iapi.productsync.parameter.MongocrudBean;
import com.ymatou.iapi.productsync.service.MongocrudCall;
import com.ymatou.iapi.productsynces.parameter.ESsearchBean;
import com.ymatou.iapi.productsynces.service.ESGodsearchCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.*;
import com.ymttest.database.annotation.SqlMapperFactory;
import com.ymttest.database.annotation.product.IntergratedProductMapper;
import com.ymttest.database.model.*;
import com.ymttest.database.model.anlihui.YmtAnlihuiProduct;
import com.ymttest.database.mongo.jproduct.*;
import com.ymttest.database.redis.ImRedisWapper;
import com.ymttest.database.sqlwapper.*;
import com.ymttest.database.sqlwapper.anlihui.YmtAnlihuiProductWrapper;
import com.ymttest.utils.*;
import org.apache.http.client.ClientProtocolException;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.*;
import org.junit.experimental.categories.Category;

import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

public class Ts_Mongocrud {
	private static MongocrudBean bean;
	private static MongocrudCall call;
	private static YmtProductActivityStockWapper productActStockWapper=new YmtProductActivityStockWapper();
	private static ModifyLiveActivityBean modifyliveactivityBean=new ModifyLiveActivityBean();
	private static ModifyLiveActivityCall modifyliveactivityCall=new ModifyLiveActivityCall();
	private static int sellerId = Integer.parseInt(EnvSetup.getData("autotest_seller1"));
	private static int globalSellerId = Integer.parseInt(EnvSetup.getData("globalSellerId"));
	private static String globalSellerName = EnvSetup.getData("globalSellerName").toString();
	private static String sellerName2 = EnvSetup.getData("productsellername");
	private static int sellerId2 = Integer.parseInt(EnvSetup.getData("productsellerid"));
	private static String activityStartId = EnvSetup.getData("productActivityStartId");
	private static String activityUser = EnvSetup.getData("AdminLoginUser");
	private static String activityPswd = EnvSetup.getData("AdminLoginPswd");
	private static int sellerId3 = Integer.parseInt(EnvSetup.getData("SellerId"));//3383
	
	private static ActivityProductsWapper productActivityStockWapper=new ActivityProductsWapper();
	private static ActivityProductsWapper activityProductsWapper=new ActivityProductsWapper();
	private  com.ymttest.database.mongo.jproduct.ProductTimeStampWapper productTimeStampWapper=new com.ymttest.database.mongo.jproduct.ProductTimeStampWapper();
	private static ProductsWapper mongoDB_productsWapper=new ProductsWapper();
	private static ProductDescExtraNewWapper productDescExtraWapper=new ProductDescExtraNewWapper();
	private static LiveProductsWapper liveProductWapper=new LiveProductsWapper();
	private static LiveRoomWapper liveRoomWapper=new LiveRoomWapper();
	private static YmtCatalogsWapper catalogdWapper=new YmtCatalogsWapper();
	private static YmtProductsWapper productMapper=new YmtProductsWapper();
	private static YmtProductsWapper ymtproductsWapper=new YmtProductsWapper();
	private static IntergratedProductMapper ipm = SqlMapperFactory
            .getIntergratedProductMapper();
	
	private static YmtProductsInActivityWapper productInActivityWapper=new YmtProductsInActivityWapper();
	private YmtActivityWapper ymtActivityWapper=new YmtActivityWapper();
	private YmtCatalogsIWapper CIWapper = new YmtCatalogsIWapper();
	private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
	private 		ImRedisWapper imRedisWapper=new ImRedisWapper();
	private YmtProductActivityStockWapper ymtProductActivityStockWapper=new YmtProductActivityStockWapper();
	private  YmtProductsIWapper YmtProductsIWapper =new YmtProductsIWapper();
	private GrouponProductsWapper mongoDB_grouponProductsWapper=new GrouponProductsWapper();
	private ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
	private ESsearchBean esbean=new ESsearchBean();
	private ESGodsearchCall godCall=new ESGodsearchCall();
//	private AddAgentProductBean addAgentProductBean;
	
	//渠道商
	private static int sellerId1 = AgentUsers.rootUserId;
	private static String sellerName1 = "NickautoTest";
	//代理商1
	private static int agentUserId1 = AgentUsers.agentUserId1;
	private static String agentUserName1 = "NickautoTest";
	//代理商2
	private static int agentUserId2 = AgentUsers.agentUserId2;
	private static String agentUserName2 = "NickautoTest";
	private static AddAgentProductCall addagentproductCall=new AddAgentProductCall();
	//渠道商->代理商1
	private static int mch_agentUserId1 = AgentUsers.agentUserId1;
	private static String mch_agentUserName1 = "NickautoTest";
	
	//vip渠道
	private static int vipRootUserId = AgentUsers.vipRootUserId;
	private static String vipRootUserName = "NickautoTest";
	//vip渠道->代理
	private static int vipAgentUserId1 = AgentUsers.vipAgentUserId1;
	private static String vipAgentUserName1 = "dgsq408897016";
	//vip渠道->代理->代理
	private static int vipAgentUserId2 = AgentUsers.vipAgentUserId2;
	private static String vipAgentUserName2 = "NickautoTest";
	
	
	//境内渠道商
	private static int domestic_sellerId = 500772053;
	private static String domestic_sellerName = "NickautoTest";
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("同步mongo");
	}
	
	@Before
	public void caseUp() {
		bean = new MongocrudBean();
		call = new MongocrudCall();	
	}
	
	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}
	
	@After
	public void caseDown() {
		Logger.end();
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_001() {
		Logger.start(true,"同步mongo-验证指令SyncLiveActivityProduct,直播商品秒杀活动");
		try{
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.comment("创建直播");
			// 5分钟后开始200分钟后结束
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			//半小时之内会锁定不能修改
			Date starttime = new Date(now.getTime() + 60 * 60 * 1000);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));
			
			
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(clive);
			Logger.comment("加入商品");
			LiveRoomCallService.AddProductsToLive(createlive.getId(), sellerId, productId);
			Logger.comment("查询商品规格");

			List<YmtCatalogsI> catalogsList = CIWapper.selectCatalogsByProductId(productId);
			List<String> cids = catalogsList.stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			Logger.comment("创建秒杀活动");
			CreateLiveActivityBean createliveactivityBean = LiveRoomCallService.initCreateLiveActivityBean(createlive.getId(), cids.get(0), 5d, 6, starttime);
			LiveRoomCallService.CreateLiveActivity(createliveactivityBean);	
			
			modifyliveactivityBean=LiveRoomCallService.initModifyLiveActivityBean(createliveactivityBean);
			//修改结束时间
			modifyliveactivityBean.getLiveActivity().setEndTime(String.valueOf(new Date(now.getTime() + 201 * 60 * 1000).getTime()));
//			//修改价格和库存
//			modifyliveactivityBean.getLiveActivity().getActivityProducts().forEach(ap->{
//				ap.setActivityStock(ap.getActivityStock()-1);
//				ap.setActivityPrice(ap.getActivityPrice()-1);
//			});
			modifyliveactivityCall.setData(modifyliveactivityBean);
			modifyliveactivityCall.callService();
			
			//修改
			int iActivityID=modifyliveactivityBean.getLiveActivity().getLiveActivityId();
			int productInActivityId=modifyliveactivityBean.getLiveActivity().getActivityProducts().get(0).getActivityProductId();
			int transactionId=TestDataManager.getRandomIntNum(9);
			int stockNum=TestDataManager.getRandomIntNum(1);

			Map map=productActStockWapper.selectBy(MapUtil.hashMap("sproductid",productId,"iactivityid",iActivityID));
			int count=productActStockWapper.updateiStockNumByProductActivityStockId(map.get("sProductActivityStockID").toString(),stockNum);
			
			int source=Integer.parseInt(map.get("sourceId").toString())+1;
			
			productActStockWapper.updateSourceIdByProductActivityStockId(map.get("sProductActivityStockID").toString(),source);
			Logger.comment("stockNum######:"+stockNum);
	       
			//修改库存stock
			Thread.sleep(5000);
			bean.setActionType("SyncLiveActivityProduct");
			bean.setActivityId(productInActivityId);//Ymt_ProductActivityStock 表中的 iProductInActivityId
			bean.setProductId(productId);
			bean.setTransactionId(transactionId);
			
			call.setData(bean);
			call.callService();
	        //验证库存stock
		    Map<String,Object> p= productActivityStockWapper.getByProdId(productId);
			
			Logger.verifyEquals(new JSONArray(p.get("catalogs").toString()).getJSONObject(0).getString("stock")
					, Integer.toString(stockNum), "验证mongo返回的库存");
			Logger.verifyEquals(p.get("atype").toString(), "1", "验证atype返回的库存");
			Logger.verifyEquals(p.get("sourceId"), source, "验证sourceId返回的库存");
			
			YmtProducts product=productMapper.selectProductByProductId(productId);
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间");
			Logger.verifyNotNull(ob.get("aut"), "验证aut活动商品更新时间不为空");
			
			Logger.verifyEquals(true,(long)ob.get("cut")>catalogsList.get(catalogsList.size()-1).getUpdateTime().getTime(), "验证cut规格更新时间");
			Logger.verifyEquals(true,(long)ob.get("sut")>product.getDlastupdate().getTime(), "验证sut商品更新时间");
			
			
			//YmtProductsInActivity  productsInActivity=productInActivityWapper.selectAllByiActivityId(activityId).get(0);
			//Logger.verifyEquals(true,(long)ob.get("aut")>sdf.parse(map.get("dUpdateTime").toString()).getTime(), "验证aut活动商品更新时间");

			Map<String,Object> map2 = new ProductTimeStampWapper().getByProductId(productId);
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map2.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map2.get("sut"))).getTime();
		    long aut_mongo=sdf.parse(sdf.format(map2.get("aut"))).getTime();

			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("aut"),aut_mongo, "验证redis aut规格更新时间与mongo一致");

		}catch(Exception e){
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_002() {
		Logger.start(true,"同步mongo-验证指令CreateProduct,新增商品");
		try{	
			//发布一个商品		
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			addpro.getProduct().setProductType(3);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.verifyNotNull(productId, "响应报文-商品ID");
			
			bean.setActionType("CreateProduct");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean); 
			call.callService();
			
		    //验证商品编号spid
		    Map<String,Object> p= mongoDB_productsWapper.getByProductId(productId);
			Logger.verifyEquals(p.get("spid").toString(), productId, "验证返回spid");
            Logger.verifyEquals(addpro.getProduct().getProductType(),Integer.parseInt(p.get("ptype").toString()), "验证传入的商品类型ptype与mongo数据库是否一致");
            
			//规格市场价
			List<String> catelogList= mongoDB_productsWapper.getByPid(productId);
			List<YmtCatalogs> catelogList_sql=new YmtCatalogsWapper().selectCatalogs(productId);
			Logger.verifyEquals(addpro.getProduct().getCatalogList().size(),catelogList.size(),"验证传入的规格 与mongo一致");
			for(int i=0;i<catelogList.size();i++)
			{
				Logger.comment("######################验证mprice######################");
				JSONObject  act=new JSONObject(catelogList.get(i).toString());
				String str_catalogId=act.getString("cid");
				List<YmtCatalogs> exp=catelogList_sql.stream()
					.filter(c->c.getScatalogid().equals(str_catalogId)).collect(Collectors.toList());
				Logger.verifyEquals(Double.parseDouble(exp.get(0).getFMarketPrice().toString()),act.getDouble("mprice"), "验证第"+i+"条传入的市场价mprice与mongo数据库是否一致");
			}	
            
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间");
			Logger.verifyEquals("null",ob.get("aut").toString(), "验证aut活动商品更新时间为空");
			
			
			System.out.println("Redis cut:"+sdf.format(new Date(Long.valueOf(ob.get("cut").toString()))));
			System.out.println("Redis sut:"+sdf.format(new Date(Long.valueOf(ob.get("sut").toString()))));

			Map<String,Object> map = new ProductTimeStampWapper().getByProductId(productId);
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map.get("sut"))).getTime();
		    
			System.out.println("mongo cut:"+sdf.format(map.get("cut")));
			System.out.println("mongo sut:"+sdf.format(map.get("sut")));

			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
			//拼邮发货类型
            YmtProducts product=productMapper.selectProductByProductId(productId); productMapper.selectProductByProductId(productId);
            Logger.verifyEquals(p.get("pdt"),product.getPackageDeliveryType(), "验证数据库ymtproduct拼邮发货类型与mongo一致");
    		
		}catch(Exception e){
			Logger.fail(e);
		}
	}


	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_003() {
		Logger.start(true,"同步mongo-验证指令ModifyProduct,修改商品");
		try{
			YmtProductsWapper productWapper=new YmtProductsWapper();
			String startTime = YMTDateUtil.getBeforeOrNextDayStr(YMTDateUtil.getBeforeOrNextDay(0), 0);
			String endTime = YMTDateUtil.getBeforeOrNextDayStr(YMTDateUtil.getBeforeOrNextDay(7), 0);
			
			//发布一个活动商品		
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.verifyNotNull(productId, "响应报文-商品ID");
            //创建商品同步指令
			createProduct_sync(productId);
			
			Logger.comment("productId:"+productId);
			YmtProducts products=productWapper.selectProductByProductId(productId);
			//修改 
			String productName="测试mongo同步_"+startTime;
			addpro.getProduct().setProductName(productName);
			addpro.getProduct().setRecomReason("修改推荐理由_"+TestDataManager.getRandomNum(2));;
			addpro.setProductSite("APP");
 			ProductManagerCallServiceV3.ModifySellerProduct(productId,addpro);

			bean.setActionType("ModifyProduct");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();
			Logger.comment("RecomReason:"+addpro.getProduct().getRecomReason());
			 //验证商品名称title
		    Map<String,Object> p= mongoDB_productsWapper.getByProductId(productId);
			Logger.verifyEquals(p.get("title").toString(), productName, "验证mongo返回的title");
			//规格市场价
			List<String> catelogList= mongoDB_productsWapper.getByPid(productId);
			List<YmtCatalogs> catelogList_sql=new YmtCatalogsWapper().selectCatalogs(productId);
			Logger.verifyEquals(addpro.getProduct().getCatalogList().size(),catelogList.size(),"验证传入的规格 与mongo一致");
			for(int i=0;i<catelogList.size();i++)
			{
				Logger.comment("######################验证mprice######################");
				JSONObject  act=new JSONObject(catelogList.get(i).toString());
				String str_catalogId=act.getString("cid");
				List<YmtCatalogs> exp=catelogList_sql.stream()
					.filter(c->c.getScatalogid().equals(str_catalogId)).collect(Collectors.toList());
				Logger.verifyEquals(Double.parseDouble(exp.get(0).getFMarketPrice().toString()),act.getDouble("mprice"), "验证第"+i+"条传入的市场价mprice与mongo数据库是否一致");
			}	
           
            YmtProducts product=productMapper.selectProductByProductId(productId);
			List<YmtCatalogsI> catalogsList = CIWapper.selectCatalogsByProductId(productId);
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间为空");
			Logger.verifyEquals("null",ob.get("aut").toString(), "验证aut活动商品更新时间为空");
			
			Logger.verifyEquals(true,(long)ob.get("cut")>catalogsList.get(catalogsList.size()-1).getUpdateTime().getTime(), "验证cut规格更新时间");
			Logger.verifyEquals(true,(long)ob.get("sut")>product.getDlastupdate().getTime(), "验证sut商品更新时间");
			//获取当前时间&结束时间
			Map<String,Object> map2 = productTimeStampWapper.getByProductId(productId);
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map2.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map2.get("sut"))).getTime();

			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
			
 			//查询规格上的佣金
			BasicDBObject search = new BasicDBObject();
			search.append("spid", productId);
			// 验证规格相关
			List<Map> clist = mongoDB_productsWapper.selectCatalogs(search, null);
			Logger.verifyEquals(null,clist.get(0).get("commissionpercent"),"验证佣金commissionpercent");
			
			//RecomReason 推荐理由（目前主要用在直播商品列表） 新增 wuwen 20200213 
			Logger.verifyEquals(p.get("recomreason").toString()
					, addpro.getProduct().getRecomReason(), "验证mongo返回的推荐理由");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}

	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_003_1() {
		Logger.start(true,"同步mongo-验证指令ModifyProduct,修改商品-spu商品");
		try{
			YmtProductsWapper productWapper=new YmtProductsWapper();
			String startTime = YMTDateUtil.getBeforeOrNextDayStr(YMTDateUtil.getBeforeOrNextDay(0), 0);
			String endTime = YMTDateUtil.getBeforeOrNextDayStr(YMTDateUtil.getBeforeOrNextDay(7), 0);
			
			//发布一个活动商品		
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerSpuProduct(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			//移除一个规格
		//	addpro.getProduct().getCatalogList().remove(1);
			
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			//spu商品编号 sppid
		//	addpro.getProduct().setSpuProductId(TestDataManager.getRandomIntNum(5));
			addpro.getProduct().setSpuId(229);
			addpro.getProduct().setSpuProductId(229);
			
			//spuCatalogId标准商品库规格id spcid
			addpro.getProduct().getCatalogList().get(0).setSpuCatalogId(11);
			//publishType 发布类型 0- 标准商品，1- 图片商品，2- 视频商品 pubtype
			addpro.getProduct().setPublishType(1);
			//ProductTags 选填，商品标签列表 tag 
			addpro.getProduct().setProductTags(Lists.newArrayList("Tags1","Tags2"));
			
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.verifyNotNull(productId, "响应报文-商品ID");
            //创建商品同步指令
			createProduct_sync(productId);
			
			Logger.comment("productId:"+productId);
			YmtProducts products=productWapper.selectProductByProductId(productId);
			//修改 
			String productName="测试mongo同步_"+startTime;
			addpro.getProduct().setProductName(productName);
			addpro.getProduct().setRecomReason("修改推荐理由_"+TestDataManager.getRandomNum(2));;
			addpro.setProductSite("APP");
			
			//新增20200521
			//spuCatalogId标准商品库规格id spcid
			addpro.getProduct().getCatalogList().get(0).setSpuCatalogId(22);
			//publishType 发布类型 0- 标准商品，1- 图片商品，2- 视频商品 pubtype
			addpro.getProduct().setPublishType(2);
			//ProductTags 选填，商品标签列表 tag 
			addpro.getProduct().setProductTags(Lists.newArrayList("uTags1","uTags2"));
			
			//addpro.getProduct().setSpuProductId(TestDataManager.getRandomIntNum(5));
			
 			ProductManagerCallServiceV3.ModifySellerProduct(productId,addpro);

			bean.setActionType("ModifyProduct");
			bean.setActivityId(0);
			bean.setProductId(productId);
			//bean.setProductId("p4239977");
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();
			Logger.comment("RecomReason:"+addpro.getProduct().getRecomReason());
			 //验证商品名称title
		    Map<String,Object> p= mongoDB_productsWapper.getByProductId(productId);
			Logger.verifyEquals(p.get("title").toString(), productName, "验证mongo返回的title");
			//规格市场价
			List<String> catelogList= mongoDB_productsWapper.getByPid(productId);
			List<YmtCatalogs> catelogList_sql=new YmtCatalogsWapper().selectCatalogs(productId);
			Logger.verifyEquals(addpro.getProduct().getCatalogList().size(),catelogList.size(),"验证传入的规格 与mongo一致");
			for(int i=0;i<catelogList.size();i++)
			{
				Logger.comment("######################验证mprice######################");
				JSONObject  act=new JSONObject(catelogList.get(i).toString());
				String str_catalogId=act.getString("cid");
				List<YmtCatalogs> exp=catelogList_sql.stream()
					.filter(c->c.getScatalogid().equals(str_catalogId)).collect(Collectors.toList());
				Logger.verifyEquals(Double.parseDouble(exp.get(0).getFMarketPrice().toString()),act.getDouble("mprice"), "验证第"+i+"条传入的市场价mprice与mongo数据库是否一致");
			}	
           
            YmtProducts product=productMapper.selectProductByProductId(productId);
			List<YmtCatalogsI> catalogsList = CIWapper.selectCatalogsByProductId(productId);
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间为空");
			Logger.verifyEquals("null",ob.get("aut").toString(), "验证aut活动商品更新时间为空");
			
			Logger.verifyEquals(true,(long)ob.get("cut")>catalogsList.get(catalogsList.size()-1).getUpdateTime().getTime(), "验证cut规格更新时间");
			Logger.verifyEquals(true,(long)ob.get("sut")>product.getDlastupdate().getTime(), "验证sut商品更新时间");
			//获取当前时间&结束时间
			Map<String,Object> map2 = productTimeStampWapper.getByProductId(productId);
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map2.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map2.get("sut"))).getTime();

			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
			
 			//查询规格上的佣金
			BasicDBObject search = new BasicDBObject();
			search.append("spid", productId);
			// 验证规格相关
			List<Map> clist = mongoDB_productsWapper.selectCatalogs(search, null);
			Logger.verifyEquals(null,clist.get(0).get("commissionpercent"),"验证佣金commissionpercent");
			
			
			//新增20200521
			Logger.verifyEquals(p.get("sppid").toString()
					, addpro.getProduct().getSpuProductId().toString(), "验证mongo返回的spu商品编号");
			//publishType 发布类型 0- 标准商品，1- 图片商品，2- 视频商品 pubtype
			Logger.verifyEquals(p.get("pubtype").toString()
					, addpro.getProduct().getPublishType().toString(), "验证mongo返回的发布类型 0- 标准商品，1- 图片商品，2- 视频商品");
			//ProductTags 选填，商品标签列表 tag 
			Logger.verifyEquals(new JSONArray(p.get("tag").toString()).length(), addpro.getProduct().getProductTags().size(), "验证传入的数据与返回的一致");
			for(int i=0;i<new JSONArray(p.get("tag").toString()).length();i++)
			{
				String tag=new JSONArray(p.get("tag").toString()).getString(i);
				Logger.verifyEquals(true
						, addpro.getProduct().getProductTags().contains(tag), "验证mongo返回的商品标签列表");
			}
			List spcids=new ArrayList();
			spcids.add(clist.get(0).get("spcid").toString());
			spcids.add(clist.get(1).get("spcid").toString());

			Logger.verifyEquals(true
					, spcids.contains(addpro.getProduct().getCatalogList().get(0).getSpuCatalogId().toString()), "验证mongo返回的spuCatalogId标准商品库规格id");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_003_2() {
		Logger.start(true,"同步mongo-验证指令ModifyProduct,修改商品-奢侈品、物流(20201202排查-买手没有当前的物流方式发布权限)");
		try{
			YmtProductsWapper productWapper=new YmtProductsWapper();
			String startTime = YMTDateUtil.getBeforeOrNextDayStr(YMTDateUtil.getBeforeOrNextDay(0), 0);
			String endTime = YMTDateUtil.getBeforeOrNextDayStr(YMTDateUtil.getBeforeOrNextDay(7), 0);
			//发布商品
			/*奢侈品
			 * 类目 1001  1002  1003
                                     品牌 10187
                                      价格在1000-99999之间
			 */
			AddSellerProductRequest addpro =ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(3383);
			addpro.getProduct().getCatalogList().get(0).setPrice(10000);
			addpro.getProduct().getCatalogList().get(0).setNewPrice(10000);
			addpro.getProduct().getCatalogList().get(0).setVipPrice(10000);
			addpro.getProduct().getCatalogList().get(0).setMarketPrice(18000);
            //物流时效
		    addpro.getProduct().setDeliveryCompanyType(1);
			addpro.getProduct().setDeliveryAging(5);
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			
			Logger.verifyNotNull(productId, "响应报文-商品ID");
            //创建商品同步指令
			createProduct_sync(productId);
			
			Logger.comment("productId:"+productId);
			YmtProducts products=productWapper.selectProductByProductId(productId);
			//修改 
			addpro.getProduct().setBrandId(13540);
			addpro.getProduct().getCatalogList().get(0).setPrice(60);
			addpro.getProduct().getCatalogList().get(0).setNewPrice(60);
			addpro.getProduct().getCatalogList().get(0).setVipPrice(60);
			addpro.getProduct().getCatalogList().get(0).setMarketPrice(60);
			
			addpro.getProduct().setDeliveryCompanyType(2);
			//addpro.getProduct().setDeliveryAging(10);
 			ProductManagerCallServiceV3.ModifySellerProduct(productId,addpro);
			bean.setActionType("ModifyProduct");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();
			Logger.comment("RecomReason:"+addpro.getProduct().getRecomReason());
			 //验证商品
		    Map<String,Object> p= mongoDB_productsWapper.getByProductId(productId);
			Logger.verifyEquals("false",p.get("lux").toString(), "验证mongo返回的lux=true:是奢侈品");
			Logger.verifyEquals(addpro.getProduct().getDeliveryCompanyType(),Integer.parseInt(p.get("dct").toString()), "验证mongo返回的dct   1.官方 2.三方");
			Logger.verifyEquals(addpro.getProduct().getDeliveryAging(),Integer.parseInt(p.get("da").toString()), "验证mongo返回的da 	 时效 天 5,10,15");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_Mongocrud_004() {
		Logger.start(true,"同步mongo-验证指令UpdateLiveTimeForEs,更新扫货线程的商品直播时间");
		try{
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.comment("创建直播");
			// 5分钟后开始200分钟后结束
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			//半小时之内会锁定不能修改
			Date starttime = new Date(now.getTime() + 60 * 60 * 1000);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));
			
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(clive);
			Logger.comment("加入商品");
			LiveRoomCallService.AddProductsToLive(createlive.getId(), sellerId, productId);
			LiveRoomCallService.UpdateLiveTimeToStart(createlive.getId());
			
//			Logger.comment("查询商品规格");
//			YmtCatalogsIWapper CIWapper = new YmtCatalogsIWapper();
//			List<String> cids = CIWapper.selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
//			Logger.comment("创建秒杀活动");
//			CreateLiveActivityBean createliveactivityBean = LiveRoomCallService.initCreateLiveActivityBean(createlive.getId(), cids.get(0), 5d, 6, starttime);
//			LiveRoomCallService.CreateLiveActivity(createliveactivityBean);	
//			
//			modifyliveactivityBean=LiveRoomCallService.initModifyLiveActivityBean(createliveactivityBean);
			//修改结束时间
//			modifyliveactivityBean.getLiveActivity().setEndTime(String.valueOf(new Date(now.getTime() + 201 * 60 * 1000).getTime()));
//			//修改价格和库存
//			modifyliveactivityBean.getLiveActivity().getActivityProducts().forEach(ap->{
//				ap.setActivityStock(ap.getActivityStock()-1);
//				ap.setActivityPrice(ap.getActivityPrice()-1);
//			});
//			modifyliveactivityCall.setData(modifyliveactivityBean);
//			modifyliveactivityCall.callService();
			
		   //获取商品在直播中的Id
			Map map=new LiveRoomWapper().selectLiveproductByLiveid(createlive.getId()).get(0);
			int liveProductId=Integer.parseInt(map.get("LiveProductId").toString());
			Logger.comment("liveProductId："+liveProductId);
	       
			//修改库存stock
			Thread.sleep(10000);
			bean.setActionType("UpdateLiveTimeForEs");
			bean.setActivityId(liveProductId);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();
//	        //验证库存stock
//		    Map<String,Object> p= productActivityStockWapper.getByProdId(productId);
//			
//			Logger.verifyEquals(new JSONArray(p.get("catalogs").toString()).getJSONObject(0).getString("stock")
//					, Integer.toString(stockNum), "验证mongo返回的库存");
//			Logger.verifyEquals(p.get("atype").toString(), "1", "验证atype返回的库存");
//			Logger.verifyEquals(p.get("sourceId"), source, "验证sourceId返回的库存");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_005() {
		Logger.start(true,"同步mongo-验证指令AddProduct,添加商品（批量）");
		try{
			//RecomReason 推荐理由（目前主要用在直播商品列表）
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
	       
			bean.setActionType("AddProduct");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			//修改库存stock
			//Thread.sleep(5000);
			
			call.setData(bean);
			call.callService();
			Logger.comment("RecomReason:"+addpro.getProduct().getRecomReason());
	        //验证
		    Map<String,Object> p= mongoDB_productsWapper.getByProductId(productId);
			
			Logger.verifyEquals(p.get("spid").toString()
					, productId, "验证mongo返回的商品id");
			
			YmtProducts product=productMapper.selectProductByProductId(productId);
			List<YmtCatalogsI> catalogsList = CIWapper.selectCatalogsByProductId(productId);
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间为空");
			Logger.verifyEquals("null",ob.get("aut").toString(), "验证aut活动商品更新时间为空");
			
			Logger.verifyEquals(true,(long)ob.get("cut")>catalogsList.get(catalogsList.size()-1).getUpdateTime().getTime(), "验证cut规格更新时间");
			Logger.verifyEquals(true,(long)ob.get("sut")>product.getDlastupdate().getTime(), "验证sut商品更新时间");
			
			//获取当前时间&结束时间
			Map<String,Object> map2 = productTimeStampWapper.getByProductId(productId);
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map2.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map2.get("sut"))).getTime();

			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
			//查询规格上的佣金
			BasicDBObject search = new BasicDBObject();
			search.append("spid", productId);
			// 验证规格相关
			List<Map> clist = mongoDB_productsWapper.selectCatalogs(search, null);
			Logger.verifyEquals(null,clist.get(0).get("commissionpercent"),"验证佣金commissionpercent");
			//RecomReason 推荐理由（目前主要用在直播商品列表） 新增 wuwen 20200213 
			Logger.verifyEquals(p.get("recomreason").toString()
					, addpro.getProduct().getRecomReason(), "验证mongo返回的商品id");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_005_1() {
		Logger.start(true,"同步mongo-验证指令AddProduct,添加商品（批量）-spu商品");
		try{
			//RecomReason 推荐理由（目前主要用在直播商品列表）
			//AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerSpuProduct(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			/*
			 * 新增字段：商品发布类型 pubtype
				新增字段：sppid（Ymt_Products.SpuProductId）
				新增字段：tag （Ymt_ProductTag）
				新增字段：as（AuditStatus）
			 */
			//spu商品编号 sppid
		//	addpro.getProduct().setSpuProductId(TestDataManager.getRandomIntNum(5));
			//spuCatalogId标准商品库规格id spcid
			addpro.getProduct().getCatalogList().get(0).setSpuCatalogId(11);
			//publishType 发布类型 0- 标准商品，1- 图片商品，2- 视频商品 pubtype
			addpro.getProduct().setPublishType(1);
			//ProductTags 选填，商品标签列表 tag
			addpro.getProduct().setProductTags(Lists.newArrayList("Tags1","Tags2"));
			
			 
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
	       
			bean.setActionType("AddProduct");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			//修改库存stock
			//Thread.sleep(5000);
			
			call.setData(bean);
			call.callService();
			Logger.comment("RecomReason:"+addpro.getProduct().getRecomReason());
	        //验证
		    Map<String,Object> p= mongoDB_productsWapper.getByProductId(productId);
			
			Logger.verifyEquals(p.get("spid").toString()
					, productId, "验证mongo返回的商品id");
			
			YmtProducts product=productMapper.selectProductByProductId(productId);
			List<YmtCatalogsI> catalogsList = CIWapper.selectCatalogsByProductId(productId);
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间为空");
			Logger.verifyEquals("null",ob.get("aut").toString(), "验证aut活动商品更新时间为空");
			
			Logger.verifyEquals(true,(long)ob.get("cut")>catalogsList.get(catalogsList.size()-1).getUpdateTime().getTime(), "验证cut规格更新时间");
			Logger.verifyEquals(true,(long)ob.get("sut")>product.getDlastupdate().getTime(), "验证sut商品更新时间");
			
			//获取当前时间&结束时间
			Map<String,Object> map2 = productTimeStampWapper.getByProductId(productId);
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map2.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map2.get("sut"))).getTime();

			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
			//查询规格上的佣金
			BasicDBObject search = new BasicDBObject();
			search.append("spid", productId);
			// 验证规格相关
			List<Map> clist = mongoDB_productsWapper.selectCatalogs(search, null);
			Logger.verifyEquals(null,clist.get(0).get("commissionpercent"),"验证佣金commissionpercent");
            //新增20200521
			Logger.verifyEquals(p.get("sppid").toString()
					, addpro.getProduct().getSpuProductId().toString(), "验证mongo返回的spu商品编号");
			
			//publishType 发布类型 0- 标准商品，1- 图片商品，2- 视频商品 pubtype
			Logger.verifyEquals(p.get("pubtype").toString()
					, addpro.getProduct().getPublishType().toString(), "验证mongo返回的发布类型 0- 标准商品，1- 图片商品，2- 视频商品");
			
			//ProductTags 选填，商品标签列表 tag 
			Logger.verifyEquals(new JSONArray(p.get("tag").toString()).length(), addpro.getProduct().getProductTags().size(), "验证传入的数据与返回的一致");
			for(int i=0;i<new JSONArray(p.get("tag").toString()).length();i++)
			{
				String tag=new JSONArray(p.get("tag").toString()).getString(i);
				Logger.verifyEquals(true
						, addpro.getProduct().getProductTags().contains(tag), "验证mongo返回的商品标签列表");
			}
			Logger.verifyEquals(clist.get(1).get("spcid").toString()
					, addpro.getProduct().getCatalogList().get(0).getSpuCatalogId().toString(), "验证mongo返回的spuCatalogId标准商品库规格id");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_Mongocrud_005_2() {
		Logger.start(true,"同步mongo-验证指令AddProduct,添加商品（批量）-奢侈品、物流(20201202排查-买手没有当前的物流方式发布权限)");
		try{
			AddSellerProductRequest addProdReq =ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(3383);
			addProdReq.getProduct().getCatalogList().get(0).setPrice(10000);
			addProdReq.getProduct().getCatalogList().get(0).setNewPrice(10000);
			addProdReq.getProduct().getCatalogList().get(0).setVipPrice(10000);
			addProdReq.getProduct().getCatalogList().get(0).setMarketPrice(18000);
            //物流时效
			addProdReq.getProduct().setDeliveryCompanyType(1);
			addProdReq.getProduct().setDeliveryAging(5);
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addProdReq);

			bean.setActionType("AddProduct");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));

			Thread.sleep(5000);
			call.setData(bean);
			call.callService();
	        //验证
		    Map<String,Object> p= mongoDB_productsWapper.getByProductId(productId);
			Logger.verifyEquals("true",p.get("lux").toString(), "验证mongo返回的lux=true:是奢侈品");
			Logger.verifyEquals(addProdReq.getProduct().getDeliveryCompanyType(),Integer.parseInt(p.get("dct").toString()), "验证mongo返回的dct   1.官方 2.三方");
			Logger.verifyEquals(addProdReq.getProduct().getDeliveryAging(),Integer.parseInt(p.get("da").toString()), "验证mongo返回的da 	 时效 天 5,10,15");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_006() {
		Logger.start(true,"同步mongo-验证指令AddProductPics,添加商品图片");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
		
			List<String> productPicList=addpro.getProduct().getProductPicList();
			productPicList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_ll.jpg");
			addpro.getProduct().setProductPicList(productPicList);
			ModifySellerProductRequest modifySellerProductRequest=ProductManagerCallServiceV2.getModifySellerProductRequestFromAddProductBean(productId,addpro);
			ModifySellerProductCall modifySellerProductCall=new ModifySellerProductCall();
			modifySellerProductCall.setData(modifySellerProductRequest);
			modifySellerProductCall.callService();
			
			//修改库存stock
			Thread.sleep(5000);
			bean.setActionType("AddProductPics");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();
	        //验证库存stock
		    Map<String,Object> p= mongoDB_productsWapper.getByProductId(productId);
		    Logger.verifyEquals(new JSONArray(p.get("pics").toString()).get(new JSONArray(p.get("pics").toString()).length()-1)
					, productPicList.get(productPicList.size()-1), "验证mongo返回的图片");
			
		    
		    YmtProducts product=productMapper.selectProductByProductId(productId);
			List<YmtCatalogsI> catalogsList = CIWapper.selectCatalogsByProductId(productId);
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间为空");
			Logger.verifyEquals("null",ob.get("aut").toString(), "验证aut活动商品更新时间为空");
			
			Logger.verifyEquals(true,(long)ob.get("cut")>catalogsList.get(catalogsList.size()-1).getUpdateTime().getTime(), "验证cut规格更新时间");
			Logger.verifyEquals(true,(long)ob.get("sut")>product.getDlastupdate().getTime(), "验证sut商品更新时间");
			
			//获取当前时间&结束时间
			Map<String,Object> map2 = productTimeStampWapper.getByProductId(productId);
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map2.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map2.get("sut"))).getTime();

//			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
//			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_007() {
		Logger.start(true,"同步mongo-验证指令BatchSetOnShelf,批量商品上架");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			
			List<String> productIds=Lists.newArrayList();
			productIds.add(productId);
			ProductManagerCallServiceV2.batchSetProductOnSale(productIds, sellerId);
			//batchSetProductOnSale
			//修改库存stock
			Thread.sleep(5000);
			bean.setActionType("BatchSetO-nShelf");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();
			Thread.sleep(5000);
//	        //验证库存stock
//		    Map<String,Object> p= mongoDB_productsWapper.getByProductId(productId);
//		    Date dt = new Date();   
//		    SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//		    
//		    Logger.comment("newstart1:"+YMTDateUtil.getFromDTSDate(p.get("newstart").toString(),""));
//		    Logger.comment("newstart2:"+YMTDateUtil.parseYMDHMSDate(formatDate.format(dt)));
//		    Logger.verifyEquals(true, YMTDateUtil.parseYMDHMSDate(YMTDateUtil.getFromDTSDate(p.get("newstart").toString(),""))
//		    		.before(YMTDateUtil.parseYMDHMSDate(formatDate.format(dt))), "验证newstart");

		    YmtProducts product=productMapper.selectProductByProductId(productId);
			List<YmtCatalogsI> catalogsList = CIWapper.selectCatalogsByProductId(productId);
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间为空");
			Logger.verifyEquals("null",ob.get("aut").toString(), "验证aut活动商品更新时间为空");
			
			Logger.verifyEquals(true,(long)ob.get("cut")>catalogsList.get(catalogsList.size()-1).getUpdateTime().getTime(), "验证cut规格更新时间");
			Logger.verifyEquals(true,(long)ob.get("sut")>product.getDlastupdate().getTime(), "验证sut商品更新时间");
			
			//获取当前时间&结束时间
			Map<String,Object> map2 = productTimeStampWapper.getByProductId(productId);
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map2.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map2.get("sut"))).getTime();

			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_008() {
		
		Logger.start(true,"同步mongo-验证指令UpdatePromotionName,修改报名活动名称(20201202排查-排除活动审核出错)");
		try{
			
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
            //创建商品同步指令
			createProduct_sync(productId);
			//获取规格ID
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			//去掉规格列表的第一个参数
			//String catalog0 = catalogs.remove(0);
			//创建一个活动  得到活动id
			Integer activityId = ProductManagerCallServiceV2.createIsolationActivityInProcess();
			
			//报名活动  获得商品在活动中的id
			List<String> aids = ProductManagerCallServiceV2.ApplyActivity(productId, sellerId,catalogs,activityId, 100,"10");
			
			//审核通过
			ProductManagerCallServiceV2.approveProductInActivity(productId,aids.get(0),true);			
			
			String startTime = YMTDateUtil.getBeforeOrNextDayStr(YMTDateUtil.getBeforeOrNextDay(0), 0);
			String productName="修改报名活动名称指令测试_"+startTime;
			new YmtActivityWapper().updateSaleSideName(activityId,productName);	
			
			bean.setActionType("UpdatePromotionName");
			bean.setActivityId(activityId);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();
			 //验证mongo
		    Map<String,Object> p= activityProductsWapper.getByProdId(productId);
		    Map<String,Object> p2= productTimeStampWapper.getByProductId(productId);
			Logger.verifyEquals(p.get("aname").toString(), productName, "验证mongo 表 activityProducts 返回的活动名称");
			Logger.verifyNotNull(p2.get("aut").toString(), "验证mongo 表 productTimeStamp 返回的uat");
			
			
			YmtProducts product=productMapper.selectProductByProductId(productId);
		    List<YmtCatalogsI> catalogsList = CIWapper.selectCatalogsByProductId(productId);

			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间");
			Logger.verifyNotNull(ob.get("aut").toString(), "验证aut活动商品更新时间不为空");
			
			
			System.out.println("Redis cut6:"+sdf.format(new Date(Long.valueOf(ob.get("cut").toString()))));
			System.out.println("Redis sut6:"+sdf.format(new Date(Long.valueOf(ob.get("sut").toString()))));
			
			Logger.verifyEquals(true,(long)ob.get("cut")>catalogsList.get(catalogsList.size()-1).getUpdateTime().getTime(), "验证cut规格更新时间");
			Logger.verifyEquals(true,(long)ob.get("sut")>product.getDlastupdate().getTime(), "验证sut商品更新时间");
			
			Map map=productActStockWapper.selectBy(MapUtil.hashMap("sproductid",productId,"iactivityid",activityId));
			
			Logger.verifyEquals(true,(long)ob.get("aut")>sdf.parse(sdf.format(map.get("dUpdateTime"))).getTime(), "验证aut活动商品更新时间");
			
			//获取当前时间&结束时间
			Map<String,Object> map6 = productTimeStampWapper.getByProductId(productId);
			System.out.println("mongo cut6:"+sdf.format(map6.get("cut")));
			System.out.println("mongo sut6:"+sdf.format(map6.get("sut")));
			
			Map<String,Object> map7 = productTimeStampWapper.getByProductId(productId);	
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map7.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map7.get("sut"))).getTime();
		    long aut_mongo=sdf.parse(sdf.format(map7.get("aut"))).getTime();

			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("aut"),aut_mongo, "验证redis aut规格更新时间与mongo一致");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_009() {
		Logger.start(true,"同步mongo-验证指令DeleteProduct,删除商品");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			
			List<String> productIds=Lists.newArrayList();
			productIds.add(productId);
			ProductManagerCallServiceV2.batchDeleteProducts(productIds, sellerId);
			
			//batchSetProductOnSale
			//修改库存stock
			Thread.sleep(5000);
			bean.setActionType("DeleteProduct");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();
	        //验证库存stock
		    Map<String,Object> p= mongoDB_productsWapper.getByProductId(productId);
		    Logger.verifyIsNull(p,"验证mongo没有数据");
		    YmtProducts product=productMapper.selectProductByProductId(productId);
		    Logger.verifyEquals(-2,product.getIaction(), "验证SQL iaction=-2");
		    
			List<YmtCatalogsI> catalogsList = CIWapper.selectCatalogsByProductId(productId);
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyNotNull(ob.get("lut").toString(), "验证lut直播商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("aut").toString(), "验证aut活动商品更新时间为空");
			
			Logger.verifyEquals(true,(long)ob.get("cut")>catalogsList.get(catalogsList.size()-1).getUpdateTime().getTime(), "验证cut规格更新时间");
			Logger.verifyEquals(true,(long)ob.get("sut")>product.getDlastupdate().getTime(), "验证sut商品更新时间");
			
			//获取当前时间&结束时间
			Map<String,Object> map2 = productTimeStampWapper.getByProductId(productId);
			
			System.out.println("mongo cut:"+sdf.format(map2.get("cut")));
			System.out.println("mongo sut:"+sdf.format(map2.get("sut")));
			
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map2.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map2.get("sut"))).getTime();
		    long lut_mongo=sdf.parse(sdf.format(map2.get("lut"))).getTime();

			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("lut"),lut_mongo, "验证redis lut规格更新时间与mongo一致");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_010() {
		Logger.start(true,"同步mongo-验证指令DeleteProductPics,删除某个商品下的图片(单选/多选)");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Map<String,Object> p1= mongoDB_productsWapper.getByProductId(productId);
			
			List<String> productPicList=addpro.getProduct().getProductPicList();
			//List arrList = new ArrayList(productPicList);
			productPicList.remove(0);
			addpro.getProduct().setProductPicList(productPicList);
			
			List<String> productIds=Lists.newArrayList();
			productIds.add(productId);
			ModifySellerProductRequest modifySellerProductRequest=ProductManagerCallServiceV2.getModifySellerProductRequestFromAddProductBean(productId, addpro);
			
			ModifySellerProductCall modifySellerProductCall=new ModifySellerProductCall();
			modifySellerProductCall.setData(modifySellerProductRequest);
			modifySellerProductCall.callService();
			
			//修改库存stock
			Thread.sleep(5000);
			bean.setActionType("DeleteProductPics");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();
	        //验证库存stock
		    Map<String,Object> p2= mongoDB_productsWapper.getByProductId(productId);
		    
		    Logger.verifyEquals(true,new JSONArray(p1.get("pics").toString()).length()-new JSONArray(p2.get("pics").toString()).length()==1
					, "验证mongo返回的图片");
		    
		    
		    YmtProducts product=productMapper.selectProductByProductId(productId);
			List<YmtCatalogsI> catalogsList = CIWapper.selectCatalogsByProductId(productId);
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间为空");
			Logger.verifyEquals("null",ob.get("aut").toString(), "验证aut活动商品更新时间为空");
			
			Logger.verifyEquals(true,(long)ob.get("cut")>catalogsList.get(catalogsList.size()-1).getUpdateTime().getTime(), "验证cut规格更新时间");
			Logger.verifyEquals(true,(long)ob.get("sut")>product.getDlastupdate().getTime(), "验证sut商品更新时间");

			//获取当前时间&结束时间
			Map<String,Object> map2 = productTimeStampWapper.getByProductId(productId);
			
			System.out.println("mongo cut:"+sdf.format(map2.get("cut")));
			System.out.println("mongo sut:"+sdf.format(map2.get("sut")));
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map2.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map2.get("sut"))).getTime();

			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_011() {
		Logger.start(true,"同步mongo-验证指令ProductPutout,商品下架");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			
			List<String> productIds=Lists.newArrayList();
			productIds.add(productId);
			ProductManagerCallServiceV2.batchSetProductOffSale(productIds, sellerId);
			//batchSetProductOnSale
			//修改库存stock
			Thread.sleep(5000);
			bean.setActionType("ProductPutout");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();
//	        //验证库存stock
//		    Map<String,Object> p= mongoDB_productsWapper.getByProductId(productId);
//		    
//		    Date dt = new Date();   
//		    SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//
//		    Logger.verifyEquals(true, YMTDateUtil.parseYMDHMSDate(YMTDateUtil.getFromDTSDate(p.get("newend").toString(),""))
//		    		.before(YMTDateUtil.parseYMDHMSDate(formatDate.format(dt))), "验证newend");
			
			YmtProducts product=productMapper.selectProductByProductId(productId);
		    List<YmtCatalogsI> catalogsList = CIWapper.selectCatalogsByProductId(productId);
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyNotNull(ob.get("lut").toString(), "验证lut直播商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("aut").toString(), "验证aut活动商品更新时间为空");
			
			Logger.verifyEquals(true,(long)ob.get("cut")>catalogsList.get(catalogsList.size()-1).getUpdateTime().getTime(), "验证cut规格更新时间");
			Logger.verifyEquals(true,(long)ob.get("sut")>product.getDlastupdate().getTime(), "验证sut商品更新时间");
			
			//不是直播商品，为什么redis同步会更新直播时间
			//获取当前时间&结束时间
			Map<String,Object> map2 = productTimeStampWapper.getByProductId(productId);
			System.out.println("mongo cut:"+sdf.format(map2.get("cut")));
			System.out.println("mongo sut:"+sdf.format(map2.get("sut")));
			System.out.println("mongo lut:"+sdf.format(map2.get("lut")));
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map2.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map2.get("sut"))).getTime();
		    long lut_mongo=sdf.parse(sdf.format(map2.get("lut"))).getTime();

			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("lut"),lut_mongo, "验证redis lut规格更新时间与mongo一致");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_012() {
		Logger.start(true,"同步mongo-验证指令ProductStockChange,修改商品库存和价格");
		try{
			
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.verifyNotNull(productId, "响应报文-商品ID");
            //创建商品同步指令
			createProduct_sync(productId);
			
			Logger.comment("productId:"+productId);
			YmtCatalogs catalogs=catalogdWapper.selectBySproductId(productId);
//			//修改 
			catalogs.setInum(1);
			int count=catalogdWapper.updateByPrimaryKey(catalogs);
			//ProductManagerCallServiceV2.updateProductStockNum(sellerId, productId, catalogs.getScatalogid(), 1);
			
			Logger.comment("CatalogId:"+catalogs.getScatalogid());
			bean.setActionType("ProductStockChange");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setCatalogId(catalogs.getScatalogid());
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();
			 //验证stock
		    Map<String,Object> p= new CatalogsWapper().getByCatalogId(catalogs.getScatalogid());
			Logger.verifyEquals(p.get("stock").toString(), "1", "验证stock返回的库存");
			
			YmtProducts product=productMapper.selectProductByProductId(productId);
		    List<YmtCatalogsI> catalogsList = CIWapper.selectCatalogsByProductId(productId);
		    
			//规格市场价
			List<String> catelogList= mongoDB_productsWapper.getByPid(productId);
			List<YmtCatalogs> catelogList_sql=new YmtCatalogsWapper().selectCatalogs(productId);
			Logger.verifyEquals(addpro.getProduct().getCatalogList().size(),catelogList.size(),"验证传入的规格 与mongo一致");
			for(int i=0;i<catelogList.size();i++)
			{
				JSONObject  act=new JSONObject(catelogList.get(i).toString());
				String str_catalogId=act.getString("cid");
				Logger.comment("######################验证mprice cid="+str_catalogId+"######################");
				List<YmtCatalogs> exp=catelogList_sql.stream()
					.filter(c->c.getScatalogid().equals(str_catalogId)).collect(Collectors.toList());
				Logger.verifyEquals(Double.parseDouble(exp.get(0).getFMarketPrice().toString()),act.getDouble("mprice"), "验证第"+i+"条传入的市场价mprice与mongo数据库是否一致");
			}
			
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间为空");
			Logger.verifyEquals("null",ob.get("aut").toString(), "验证aut活动商品更新时间为空");
			
			Logger.verifyEquals(true,(long)ob.get("cut")>catalogsList.get(catalogsList.size()-1).getUpdateTime().getTime(), "验证cut规格更新时间");
			Logger.verifyEquals(true,(long)ob.get("sut")>product.getDlastupdate().getTime(), "验证sut商品更新时间");
			
			
			Map<String,Object> map2 = new ProductTimeStampWapper().getByProductId(productId);
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map2.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map2.get("sut"))).getTime();

			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
              
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_013() {
		Logger.start(true,"同步mongo-验证指令UpdateSensitiveWord,更新商品敏感词");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			
			ModifySellerProductRequest modifySellerProductRequest=ProductManagerCallServiceV2.getModifySellerProductRequestFromAddProductBean(productId, addpro);
			modifySellerProductRequest.getProduct().setProductName("测试商品名称SB");//关键子是SB
			ModifySellerProductCall modifySellerProductCall=new ModifySellerProductCall();
			modifySellerProductCall.setData(modifySellerProductRequest);
			modifySellerProductCall.callService();
			
			new UpdateProductSensitiveWordCall().call(productId, sellerId, 1, "SB");//propertyType（1- 商品名称，2- 商品文描文字部分，3- 规格名称，4-套装名称， 5-买家须知，6-买手介绍）
			
			//修改库存stock
			bean.setActionType("UpdateSensitiveWord");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();
			Thread.sleep(5000);
			
	        //验证库存stock
		    Map<String,Object> p1= mongoDB_productsWapper.getByProductId(productId);
		    Logger.verifyEquals("测试商品名称**",p1.get("title").toString(), "验证mongo返回的商品名称");
			
			YmtProducts product=productMapper.selectProductByProductId(productId);
		    List<YmtCatalogsI> catalogsList = CIWapper.selectCatalogsByProductId(productId);
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间为空");
			Logger.verifyEquals("null",ob.get("aut").toString(), "验证aut活动商品更新时间为空");
			
			Logger.verifyEquals(true,(long)ob.get("cut")>catalogsList.get(catalogsList.size()-1).getUpdateTime().getTime(), "验证cut规格更新时间");
			Logger.verifyEquals(true,(long)ob.get("sut")>product.getDlastupdate().getTime(), "验证sut商品更新时间");
			
			Map<String,Object> map2 = new ProductTimeStampWapper().getByProductId(productId);
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map2.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map2.get("sut"))).getTime();

			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_Mongocrud_014() {
		Logger.start(true,"同步mongo-验证指令SetOffTop,设置取消推荐置顶商品,与 Ymt_ProductsInLive（商品关联直播表） 有关，此功能已经不存在");
		try{
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.comment("创建直播");
			// 5分钟后开始200分钟后结束
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			//半小时之内会锁定不能修改
			Date starttime = new Date(now.getTime() + 60 * 60 * 1000);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));
			
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(clive);
			Logger.comment("加入商品");
			Logger.comment("####createlive.getId()######:"+createlive.getId());
			Logger.comment("####productId######:"+productId);
			LiveRoomCallService.AddProductsToLive(createlive.getId(), sellerId, productId);
			Logger.comment("查询商品规格");
			YmtCatalogsIWapper CIWapper = new YmtCatalogsIWapper();
			List<String> cids = CIWapper.selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			Logger.comment("创建秒杀活动");
			CreateLiveActivityBean createliveactivityBean = LiveRoomCallService.initCreateLiveActivityBean(createlive.getId(), cids.get(0), 5d, 6, starttime);
			LiveRoomCallService.CreateLiveActivity(createliveactivityBean);	
			
			modifyliveactivityBean=LiveRoomCallService.initModifyLiveActivityBean(createliveactivityBean);
			//修改结束时间
			modifyliveactivityBean.getLiveActivity().setEndTime(String.valueOf(new Date(now.getTime() + 201 * 60 * 1000).getTime()));
			//修改价格和库存
			modifyliveactivityCall.setData(modifyliveactivityBean);
			modifyliveactivityCall.callService();
			LiveRoomWapper liveroomWapper=new LiveRoomWapper();
			Map mapliveroom=liveroomWapper.selectLiveproductByIdAndPid(createlive.getId(), productId).get(0);
			Logger.comment("liveProductId:"+Integer.parseInt(mapliveroom.get("LiveProductId").toString()));
			int count=liveroomWapper.updateLiveProductStatusById(Integer.parseInt(mapliveroom.get("LiveProductId").toString()), 0, 1, 0);
			
			//修改库存stock
			bean.setActionType("SetOffTop");
			bean.setActivityId(modifyliveactivityBean.getLiveActivity().getLiveActivityId());
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();	 
			//直播商品更新-istop,status
//			//验证库存stock
//		    Map<String,Object> p1= liveProductWapper.getByProductId(productId);
//		    Logger.verifyEquals("0",p1.get("istop").toString(), "验证mongo返回的置顶字段istop");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_Mongocrud_015() {
		Logger.start(true,"同步mongo-验证指令SetOnTop,设置推荐置顶商品,与 Ymt_ProductsInLive（商品关联直播表） 有关，此功能已经不存在");
		try{
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.comment("创建直播");
			// 5分钟后开始200分钟后结束
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			//半小时之内会锁定不能修改
			Date starttime = new Date(now.getTime() + 60 * 60 * 1000);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));
			
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(clive);
			Logger.comment("加入商品");
			LiveRoomCallService.AddProductsToLive(createlive.getId(), sellerId, productId);
			Logger.comment("查询商品规格");
			YmtCatalogsIWapper CIWapper = new YmtCatalogsIWapper();
			List<String> cids = CIWapper.selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			Logger.comment("创建秒杀活动");
			CreateLiveActivityBean createliveactivityBean = LiveRoomCallService.initCreateLiveActivityBean(createlive.getId(), cids.get(0), 5d, 6, starttime);
			LiveRoomCallService.CreateLiveActivity(createliveactivityBean);	
			
			modifyliveactivityBean=LiveRoomCallService.initModifyLiveActivityBean(createliveactivityBean);
			//修改结束时间
			modifyliveactivityBean.getLiveActivity().setEndTime(String.valueOf(new Date(now.getTime() + 201 * 60 * 1000).getTime()));
			//修改价格和库存
			modifyliveactivityCall.setData(modifyliveactivityBean);
			modifyliveactivityCall.callService();
			LiveRoomWapper liveroomWapper=new LiveRoomWapper();
			Map mapliveroom=liveroomWapper.selectLiveproductByIdAndPid(createlive.getId(), productId).get(0);
			Logger.comment("liveProductId:"+Integer.parseInt(mapliveroom.get("LiveProductId").toString()));
			int count=liveroomWapper.updateLiveProductStatusById(Integer.parseInt(mapliveroom.get("LiveProductId").toString()), 1, 1, 0);
			
			//修改库存stock
			bean.setActionType("SetOnTop");
			bean.setActivityId(modifyliveactivityBean.getLiveActivity().getLiveActivityId());
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();	        
			//验证库存stock
		    Map<String,Object> p1= liveProductWapper.getByProductId(productId);
		    Logger.verifyEquals("1",p1.get("istop").toString(), "验证mongo返回的置顶字段istop");
		    
		    
		    
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_016() {
		Logger.start(true,"同步mongo-验证指令ModifyPutawayProductInfo,修改上架商品信息(批量)");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			
			List<String> productIds=Lists.newArrayList();
			productIds.add(productId);
			ProductManagerCallServiceV2.batchSetProductOnSale(productIds, sellerId);
			//修改库存stock
			Thread.sleep(10000);
			bean.setActionType("ModifyPutawayProductInfo");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();
	        //验证
		    Map<String,Object> p= mongoDB_productsWapper.getByProductId(productId);
		    
		    Date dt = new Date();   
		    SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		    
		    Logger.comment("newstart1:"+YMTDateUtil.getFromDTSDate(p.get("newstart").toString(),""));
		    Logger.comment("newstart2:"+YMTDateUtil.parseYMDHMSDate(formatDate.format(dt)));
		    Logger.verifyEquals(true, YMTDateUtil.parseYMDHMSDate(YMTDateUtil.getFromDTSDate(p.get("newstart").toString(),""))
		    		.before(YMTDateUtil.parseYMDHMSDate(formatDate.format(dt))), "验证newstart");
		    
			YmtProducts product=productMapper.selectProductByProductId(productId);
		    List<YmtCatalogsI> catalogsList = CIWapper.selectCatalogsByProductId(productId);
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间为空");
			Logger.verifyEquals("null",ob.get("aut").toString(), "验证aut活动商品更新时间为空");
			
			Logger.verifyEquals(true,(long)ob.get("cut")>catalogsList.get(catalogsList.size()-1).getUpdateTime().getTime(), "验证cut规格更新时间");
			Logger.verifyEquals(true,(long)ob.get("sut")>product.getDlastupdate().getTime(), "验证sut商品更新时间");
			
			Map<String,Object> map2 = new ProductTimeStampWapper().getByProductId(productId);
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map2.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map2.get("sut"))).getTime();

			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_Mongocrud_017() {
		//修改商品模板的频率过高，请稍后重试
		Logger.start(true,"同步mongo-验证指令ModifyDescTemplate,编辑商品描述模板--(研发黑五前修改模版5分钟跑一次，先暂时停止跑)");
		try{
			SellerProductCallService.deleteTemplate(sellerId);
			SaveProductTemplateBean saveProductTemplateBean=new SaveProductTemplateBean();
			saveProductTemplateBean.setDescription("测试模板");
			saveProductTemplateBean.setPicUrls(Arrays.asList("http://pic1.ymatou.com/G01/shangou/M00/3E/27/rBBlD1tpVJCAHMkLAAH4S4MXnxE909_375_667_n_w_o.jpg"));
			//Integer productTemplateId = TestDataManager.getRandomIntNum(10);
			//saveProductTemplateBean.setProductTemplateId(productTemplateId);
			saveProductTemplateBean.setSellerId(sellerId);
			saveProductTemplateBean.setTemplateName("Test_00" + TestDataManager.getRandomIntNum(5));
			saveProductTemplateBean.setTemplateType(2);
			
			SaveProductTemplateCall saveProductTemplateCall=new SaveProductTemplateCall();
			saveProductTemplateCall.setData(saveProductTemplateBean);
			saveProductTemplateCall.callService();
			
			int templateId=Integer.parseInt(new JSONObject(new JSONObject(saveProductTemplateCall.getReturnData()).get("Data").toString()).get("ProductTemplateId").toString());
			//添加商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			addpro.getProduct().getDescModel().setBuyerNoticeId(templateId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			//修改模版
			String description="更改测试模板描述_"+ TestDataManager.getRandomIntNum(5);
			String templateName="更改测试模板_"+ TestDataManager.getRandomIntNum(5);
			String picurls="http://pic1.ymatou.com/G01/shangou/M00/3E/27/rBBlD1tpVJCAHMkLAAH4S4MXnxE909_375_667_n_w_o11.jpg";
			saveProductTemplateBean.setProductTemplateId(templateId);
			saveProductTemplateBean.setSellerId(sellerId);
			saveProductTemplateBean.setTemplateName("Test_00" + TestDataManager.getRandomIntNum(5));
			saveProductTemplateBean.setPicUrls(Lists.newArrayList(picurls));
			saveProductTemplateBean.setDescription(description);
			saveProductTemplateBean.setTemplateType(2);

		    saveProductTemplateCall=new SaveProductTemplateCall();
			saveProductTemplateCall.setData(saveProductTemplateBean);
			saveProductTemplateCall.callService();
			//修改库存stock
			//Thread.sleep(10000);
			bean.setActionType("ModifyDescTemplate");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();
			Thread.sleep(5000);
	        //验证
		    Map<String,Object> p= productDescExtraWapper.getByProductId(productId);
		    
		    Logger.verifyEquals(description, p.get("notice").toString(), "验证mongo 字段notice");
		    Logger.verifyEquals(picurls, new JSONArray(new JSONObject(p).get("notipics").toString()).get(0), "验证mongo 字段picurls");
		    
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间为空");
			Logger.verifyEquals("null",ob.get("aut").toString(), "验证aut活动商品更新时间为空");
			
			Map<String,Object> map2 = new ProductTimeStampWapper().getByProductId(productId);
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map2.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map2.get("sut"))).getTime();

			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_019() {
		Logger.start(true,"同步mongo-验证指令ModifyPutawayProductInfo,修改上架商品信息(批量)");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			
			List<String> productIds=Lists.newArrayList();
			productIds.add(productId);
			ProductManagerCallServiceV2.batchSetProductOnSale(productIds, sellerId);
			
			YmtCatalogs catalogs=catalogdWapper.selectBySproductId(productId);
			//修改 
			ProductManagerCallServiceV2.updateProductStockNum(sellerId, productId, catalogs.getScatalogid(), 2);
			
			
			bean.setActionType("ModifyPutawayProductInfo");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();
	        //验证
		    Map<String,Object> p= new CatalogsWapper().getByCatalogId(catalogs.getScatalogid());
			Logger.verifyEquals(p.get("stock").toString(), "2", "验证stock返回的库存");
		    
			YmtProducts product=productMapper.selectProductByProductId(productId);
		    List<YmtCatalogsI> catalogsList = CIWapper.selectCatalogsByProductId(productId);
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间为空");
			Logger.verifyEquals("null",ob.get("aut").toString(), "验证aut活动商品更新时间为空");
			
			Logger.verifyEquals(true,(long)ob.get("cut")>catalogsList.get(catalogsList.size()-1).getUpdateTime().getTime(), "验证cut规格更新时间");
			Logger.verifyEquals(true,(long)ob.get("sut")>product.getDlastupdate().getTime(), "验证sut商品更新时间");
			
			Map<String,Object> map2 = new ProductTimeStampWapper().getByProductId(productId);
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map2.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map2.get("sut"))).getTime();

//			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
//			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_020() {
		Logger.start(true,"同步mongo-验证指令ModifyReadyPutawayProductInfo,修改商品待上架信息(批量)");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			//同步商品
			this.createProduct_sync(productId);
			
			List<String> productIds=Lists.newArrayList();
			productIds.add(productId);
			
			YmtCatalogs catalogs=catalogdWapper.selectBySproductId(productId);
			//修改 
			ProductManagerCallServiceV2.updateProductStockNum(sellerId, productId, catalogs.getScatalogid(), 2);
			
			ProductManagerCallServiceV2.batchSetProductOnSale(productIds, sellerId);
	
			bean.setActionType("ModifyReadyPutawayProductInfo");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();
	        //验证
		    Map<String,Object> p= new CatalogsWapper().getByCatalogId(catalogs.getScatalogid());
			Logger.verifyEquals(p.get("stock").toString(), "2", "验证stock返回的库存");
			
			YmtProducts product=productMapper.selectProductByProductId(productId);
		    List<YmtCatalogsI> catalogsList = CIWapper.selectCatalogsByProductId(productId);
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间为空");
			Logger.verifyEquals("null",ob.get("aut").toString(), "验证aut活动商品更新时间为空");
			
			Logger.verifyEquals(true,(long)ob.get("cut")>catalogsList.get(catalogsList.size()-1).getUpdateTime().getTime(), "验证cut规格更新时间");
			Logger.verifyEquals(true,(long)ob.get("sut")>product.getDlastupdate().getTime(), "验证sut商品更新时间");
		    
			Map<String,Object> map2 = new ProductTimeStampWapper().getByProductId(productId);
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map2.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map2.get("sut"))).getTime();

			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_021() {
		Logger.start(true,"同步mongo-验证指令ActivityStockChange,交易更新商品活动库存");
		try{
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.comment("创建直播");
			// 5分钟后开始200分钟后结束
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			//半小时之内会锁定不能修改
			Date starttime = new Date(now.getTime() + 60 * 60 * 1000);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));
			
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(clive);
			Logger.comment("加入商品");
			LiveRoomCallService.AddProductsToLive(createlive.getId(), sellerId, productId);
			Logger.comment("查询商品规格");
			YmtCatalogsIWapper CIWapper = new YmtCatalogsIWapper();
			List<String> cids = CIWapper.selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			Logger.comment("创建秒杀活动");
			CreateLiveActivityBean createliveactivityBean = LiveRoomCallService.initCreateLiveActivityBean(createlive.getId(), cids.get(0), 5d, 6, starttime);
			LiveRoomCallService.CreateLiveActivity(createliveactivityBean);	
			
			modifyliveactivityBean=LiveRoomCallService.initModifyLiveActivityBean(createliveactivityBean);
			//修改结束时间
			modifyliveactivityBean.getLiveActivity().setEndTime(String.valueOf(new Date(now.getTime() + 201 * 60 * 1000).getTime()));

			modifyliveactivityCall.setData(modifyliveactivityBean);
			modifyliveactivityCall.callService();
			
			//修改
			int iActivityID=modifyliveactivityBean.getLiveActivity().getLiveActivityId();
			int productInActivityId=modifyliveactivityBean.getLiveActivity().getActivityProducts().get(0).getActivityProductId();
			int transactionId=TestDataManager.getRandomIntNum(9);
			int stockNum=TestDataManager.getRandomIntNum(1);

			Map map=productActStockWapper.selectBy(MapUtil.hashMap("sproductid",productId,"iactivityid",iActivityID));
			int count=productActStockWapper.updateiStockNumByProductActivityStockId(map.get("sProductActivityStockID").toString(),stockNum);
			Logger.comment("stockNum######:"+stockNum);
	       
			//修改库存stock
			bean.setActionType("ActivityStockChange");
			bean.setActivityId(productInActivityId);
			bean.setProductId(productId);
			bean.setTransactionId(transactionId);
			bean.setCatalogId(map.get("sCatalogID").toString());// 规格Id，目前用于交易（包括活动商品）更新库存
			
			call.setData(bean);
			call.callService();
	        //验证库存stock
		    Map<String,Object> p= productActivityStockWapper.getByProdId(productId);
			Logger.verifyEquals(new JSONArray(p.get("catalogs").toString()).getJSONObject(0).getString("stock")
					, Integer.toString(stockNum), "验证mongo返回的库存");
			
			YmtProducts product=productMapper.selectProductByProductId(productId);
		    List<YmtCatalogsI> catalogsList = CIWapper.selectCatalogsByProductId(productId);
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间为空");
			Logger.verifyNotNull(ob.get("aut").toString(), "验证aut活动商品更新时间为空");
			Logger.verifyEquals(true,(long)ob.get("cut")>catalogsList.get(catalogsList.size()-1).getUpdateTime().getTime(), "验证cut规格更新时间");
			Logger.verifyEquals(true,(long)ob.get("sut")>product.getDlastupdate().getTime(), "验证sut商品更新时间");

//			Logger.verifyEquals(true,(long)ob.get("aut")>sdf.parse(map.get("dUpdateTime").toString()).getTime(), "验证aut活动商品更新时间");
			
			Map<String,Object> map2 = new ProductTimeStampWapper().getByProductId(productId);
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map2.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map2.get("sut"))).getTime();
		    long aut_mongo=sdf.parse(sdf.format(map2.get("aut"))).getTime();

			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("aut"),aut_mongo, "验证redis aut规格更新时间与mongo一致");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_022() {
		Logger.start(true,"同步mongo-验证指令CatalogStockChange,交易更新商品规格库存");
		try{
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);//sellerId
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			YmtCatalogs catalogs=catalogdWapper.selectBySproductId(productId);
			
			int transactionId=TestDataManager.getRandomIntNum(9);
			int stockNum=TestDataManager.getRandomIntNum(1);
			catalogs.setInum(stockNum);
			int count=catalogdWapper.updateByPrimaryKey(catalogs);
			
			//ProductManagerCallServiceV2.updateProductStockNum(sellerId, productId, catalogs.getScatalogid(), stockNum);

			Logger.comment("stockNum######:"+stockNum);
	       
			//修改库存stock
			bean.setActionType("CatalogStockChange");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(transactionId);
			bean.setCatalogId(catalogs.getScatalogid());// 规格Id，目前用于交易（包括活动商品）更新库存
			
			call.setData(bean);
			call.callService();
			Thread.sleep(10000);
	        //验证库存stock
		    Map<String,Object> p= new CatalogsWapper().getByCatalogId(catalogs.getScatalogid());
			Logger.verifyEquals(Integer.parseInt(p.get("stock").toString())
					, stockNum, "验证mongo返回的库存");
	
			YmtProducts product=productMapper.selectProductByProductId(productId);
		    List<YmtCatalogsI> catalogsList = CIWapper.selectCatalogsByProductId(productId);
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间为空");
			Logger.verifyEquals("null",ob.get("aut").toString(), "验证aut活动商品更新时间为空");
			Logger.verifyEquals(true,(long)ob.get("cut")>catalogsList.get(catalogsList.size()-1).getUpdateTime().getTime(), "验证cut规格更新时间");
			Logger.verifyEquals(true,(long)ob.get("sut")>product.getDlastupdate().getTime(), "验证sut商品更新时间");
			
			Map<String,Object> map2 = new ProductTimeStampWapper().getByProductId(productId);
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map2.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map2.get("sut"))).getTime();

			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");

			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_023() {
		Logger.start(true,"同步mongo-验证指令ModifyBrandAndCategory,修改商品分类品牌");
		try{
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Thread.sleep(5000);
			YmtProducts product=ymtproductsWapper.selectProductByProductId(productId);
//			product.setIbrandid(100);
//			product.setIcategoryid(1003);
			product.setIbrandid(10063);
			product.setIcategoryid(1004);
			int count=ymtproductsWapper.updateByPrimaryKey(product);
			
			int transactionId=TestDataManager.getRandomIntNum(9);
	       
			//修改库存stock
			bean.setActionType("ModifyBrandAndCategory");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(transactionId);
			
			call.setData(bean);
			call.callService();
			Thread.sleep(5000);
			
	        //验证库存stock
		    Map<String,Object> p= new ProductsWapper().getByProductId(productId);
			Logger.verifyEquals(p.get("brand").toString()
					, "三叶草", "验证mongo返回的品牌");
			Logger.verifyEquals(p.get("scatid").toString()
					, product.getIcategoryid().toString(), "验证mongo返回的分类");
		    Logger.verifyEquals(p.get("tcatname").toString()
							, "按键手机", "验证mongo返回的三级分类名称");
		    Logger.verifyEquals(p.get("scatname").toString()
							, "按键手机", "验证mongo返回的二级分类名称");
			Logger.verifyEquals(p.get("mcatname").toString()
							, "手机通讯", "验证mongo返回的一级分类名称");
				
		    List<YmtCatalogsI> catalogsList = CIWapper.selectCatalogsByProductId(productId);
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间为空");
			Logger.verifyEquals("null",ob.get("aut").toString(), "验证aut活动商品更新时间为空");
			Logger.verifyEquals(true,(long)ob.get("cut")>catalogsList.get(catalogsList.size()-1).getUpdateTime().getTime(), "验证cut规格更新时间");
			Logger.verifyEquals(true,(long)ob.get("sut")>product.getDlastupdate().getTime(), "验证sut商品更新时间");
			
			Map<String,Object> map2 = new ProductTimeStampWapper().getByProductId(productId);
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map2.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map2.get("sut"))).getTime();

			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_024() {
		Logger.start(true,"同步mongo-验证指令SetPspStatus,设置psp状态");
		try{

			int sellerId=Integer.valueOf(EnvSetup.getData("productpriceSellerId"));
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			
			IntergratedProductMapper ipm = SqlMapperFactory
                    .getIntergratedProductMapper();
            ipm.insertProductInfo(productId,sellerId);
            
			int result=new YmtProductsIWapper().updatePspStatus(productId, 3);
			System.out.println("#########result:"+result);
			SetPspStatusBean setpspstatusBean = new SetPspStatusBean();
			SetPspStatusCall setpspstatusCall = new SetPspStatusCall();
			
			setpspstatusBean.setIsPassViolate(true);
			setpspstatusBean.setIsRemovePsp(false);
			setpspstatusBean.setProductId(productId);
			setpspstatusBean.setSellerId(sellerId);
			setpspstatusCall.setData(setpspstatusBean);
			setpspstatusCall.callService();	
			Thread.sleep(5000);
			int transactionId=TestDataManager.getRandomIntNum(9);
			//修改
			bean.setActionType("SetPspStatus");//Ymt_ProductPspInfo表字段 PspStatus=4 CheckStatus=1，帐号要是全球优选（1：待优化 2：待加入优选 3：优选待审，4优选商品）
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(transactionId);
			
			call.setData(bean);
			call.callService();
			Thread.sleep(2000);
	        //验证
		    Map<String,Object> p= new ProductsWapper().getByProductId(productId);
			Logger.verifyEquals("true",p.get("ispsp").toString()
					, "验证mongo返回的ispsp");
			
			YmtProducts product=productMapper.selectProductByProductId(productId);
		    List<YmtCatalogsI> catalogsList = CIWapper.selectCatalogsByProductId(productId);
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间为空");
			Logger.verifyEquals("null",ob.get("aut").toString(), "验证aut活动商品更新时间为空");
			Logger.verifyEquals(true,(long)ob.get("cut")>catalogsList.get(catalogsList.size()-1).getUpdateTime().getTime(), "验证cut规格更新时间");
			Logger.verifyEquals(true,(long)ob.get("sut")>product.getDlastupdate().getTime(), "验证sut商品更新时间");
			
			Map<String,Object> map2 = new ProductTimeStampWapper().getByProductId(productId);
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map2.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map2.get("sut"))).getTime();

			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_025() {
		Logger.start(true,"同步mongo-验证指令SyncActivityProduct,同步活动商品(20201202排查-排除活动审核出错)");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);	
			});
			
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			//同步商品
			this.createProduct_sync(productId);
			//获取规格ID
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			//去掉规格列表的第一个参数
			//String catalog0 = catalogs.remove(0);
			//创建一个活动  得到活动id
			Integer activityId = ProductManagerCallServiceV2.createIsolationActivityInProcess();
			
			//报名活动  获得商品在活动中的id
			List<String> aids = ProductManagerCallServiceV2.ApplyActivity(productId, sellerId,catalogs,activityId, 100,"10");
			
			//审核通过
			ProductManagerCallServiceV2.approveProductInActivity(productId,aids.get(0),true);
			
			String startTime = YMTDateUtil.getBeforeOrNextDayStr(YMTDateUtil.getBeforeOrNextDay(0), 0);
			String productName="修改报名活动名称指令测试_"+startTime;
			new YmtActivityWapper().updateSaleSideName(activityId,productName);
			
			YmtProductsInActivity  productsInActivity=productInActivityWapper.selectAllByiActivityId(activityId).get(0);
			Thread.sleep(5000);
			bean.setActionType("SyncActivityProduct");
			bean.setActivityId(productsInActivity.getIproductinactivityid());
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();
			YmtActivityTemplateWapper ymtActivityTempWapper=new YmtActivityTemplateWapper();
			
			YmtActivity ymtActivity=ymtActivityWapper.getRecordByActivityId(activityId);
			YmtActivityTemplate temp=ymtActivityTempWapper.selectActivityTemplateById(ymtActivity.getIactivitytemplateid());
			// 验证mongo
		    Map<String,Object> p= activityProductsWapper.getByProdId(productId);
			Logger.verifyEquals(p.get("aname").toString(), productName, "验证mongo 表 activityProducts 返回的活动名称");
			Logger.verifyEquals(p.get("alevel").toString(), temp.getActivityLevel().toString(),"验证mongo 表 alevel ");
			
			YmtProducts product=productMapper.selectProductByProductId(productId);
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间");
			Logger.verifyNotNull(ob.get("aut"), "验证aut活动商品更新时间不为空");
			
//			Logger.verifyEquals(true,(long)ob.get("cut")>catalogsList.get(catalogsList.size()-1).getUpdateTime().getTime(), "验证cut规格更新时间");
//			Logger.verifyEquals(true,(long)ob.get("sut")>product.getDlastupdate().getTime(), "验证sut商品更新时间");
//			
			Logger.verifyEquals(true,(long)ob.get("aut")>productsInActivity.getDaddtime().getTime(), "验证aut活动商品更新时间");	
			
			Map<String,Object> map7 = productTimeStampWapper.getByProductId(productId);	
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map7.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map7.get("sut"))).getTime();
		    long aut_mongo=sdf.parse(sdf.format(map7.get("aut"))).getTime();

			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("aut"),aut_mongo, "验证redis aut规格更新时间与mongo一致");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_026() {
		Logger.start(true,"同步mongo-验证指令SyncActivityProduct,如果是预售商品，缴纳保证金则同步");
		try{
            AuditProductActivityStockBean activityStockBean = ProdStockCallService.initAuditProductActivityStockBean(sellerId);
            String BeginTime = YMTDateUtil.getBeforeOrNextHour(-1, YMTDateUtil.YMDTHMS_STRING);
            activityStockBean.setBeginTime(BeginTime);
            String EndTime = YMTDateUtil.getBeforeOrNextHour(1, YMTDateUtil.YMDTHMS_STRING);
            activityStockBean.setEndTime(EndTime);
            activityStockBean.setActivityType(2);//1:普通 2：预售
          
            for(int i=0;i<activityStockBean.getFBXCatalogLockList().size();i++){
	            activityStockBean.getFBXCatalogLockList().get(i).setEarnest(10);//定金（预售活动必填）
	            activityStockBean.getFBXCatalogLockList().get(i).setEarnestDedution(15);//定金立减（预售活动必填）
	            activityStockBean.getFBXCatalogLockList().get(i).setAction(0);//是否删除 -1 删除，0 正常，缴了保证金 1预售,未缴保证金
            }
            ProdStockCallService.AuditProductActivityStock(activityStockBean);
            
			String productId=activityStockBean.getProductID();
//			//修改Ymt_ProductActivityStock 表的 Action=0 缴了保证金
//			ymtProductActivityStockWapper.updateiActionByActivityIdAndProductId(0, productId,activityStockBean.getActivityID());

			
			String startTime = YMTDateUtil.getBeforeOrNextDayStr(YMTDateUtil.getBeforeOrNextDay(0), 0);
			String productName="修改报名活动名称指令测试_"+startTime;
			new YmtActivityWapper().updateSaleSideName(activityStockBean.getActivityID(),productName);
//			
			YmtProductsInActivity  productsInActivity=productInActivityWapper.selectAllByiActivityId(activityStockBean.getActivityID()).get(0);
			
			Logger.comment("##############productsInActivity.getIproductinactivityid():"+activityStockBean.getProductActivityId());
			bean.setActionType("SyncActivityProduct"); 
			bean.setActivityId(productsInActivity.getIproductinactivityid());
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();
			
			YmtActivityTemplateWapper ymtActivityTempWapper=new YmtActivityTemplateWapper();
//			
			YmtActivity ymtActivity=ymtActivityWapper.getRecordByActivityId(activityStockBean.getActivityID());
			YmtActivityTemplate temp=ymtActivityTempWapper.selectActivityTemplateById(ymtActivity.getIactivitytemplateid());
			// 验证mongo
		    Map<String,Object> p= activityProductsWapper.getByProdId(productId);
			Logger.verifyEquals(p.get("aname").toString(), productName, "验证mongo 表 activityProducts 返回的活动名称");
			Logger.verifyEquals(p.get("alevel").toString(), temp.getActivityLevel().toString(),"验证mongo 表 alevel ");
			
			Logger.verifyEquals(new JSONObject(new JSONArray(p.get("catalogs").toString()).get(0).toString()).get("atype"), 2,"验证mongo表规格上的atype ");
			Logger.verifyEquals(new JSONObject(new JSONArray(p.get("catalogs").toString()).get(1).toString()).get("atype"), 2,"验证mongo表规格上的atype ");
			Logger.verifyEquals(new JSONObject(new JSONArray(p.get("catalogs").toString()).get(0).toString()).get("earnest"), 10,"验证mongo表规格上的earnest定金 ");
			Logger.verifyEquals(new JSONObject(new JSONArray(p.get("catalogs").toString()).get(1).toString()).get("earnest"), 10,"验证mongo表规格上的earnest 定金");
			Logger.verifyEquals(new JSONObject(new JSONArray(p.get("catalogs").toString()).get(0).toString()).get("ededution"), 15,"验证mongo表规格上的ededution 定金立减金额");
			Logger.verifyEquals(new JSONObject(new JSONArray(p.get("catalogs").toString()).get(1).toString()).get("ededution"), 15,"验证mongo表规格上的ededution 定金立减金额");
			
			Logger.verifyEquals(p.get("earnest"), 10.0,"验证mongo表最外层earnest ");
			Logger.verifyEquals(p.get("ededution"), 15.0,"验证mongo表最外层ededution ");
			
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间");
			Logger.verifyNotNull(ob.get("aut"), "验证aut活动商品更新时间不为空");
			
			
			Map<String,Object> map7 = productTimeStampWapper.getByProductId(productId);	
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map7.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map7.get("sut"))).getTime();
		    long aut_mongo=sdf.parse(sdf.format(map7.get("aut"))).getTime();

			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("aut"),aut_mongo, "验证redis aut规格更新时间与mongo一致");
				
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}


	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_027() {
		Logger.start(true,"同步mongo-验证指令SyncActivityProduct,如果是预售商品，缴纳保证金则同步，两个规格上的预售价不一样");
		try{
            AuditProductActivityStockBean activityStockBean = ProdStockCallService.initAuditProductActivityStockBean(sellerId);
            String BeginTime = YMTDateUtil.getBeforeOrNextHour(-1, YMTDateUtil.YMDTHMS_STRING);
            activityStockBean.setBeginTime(BeginTime);
            String EndTime = YMTDateUtil.getBeforeOrNextHour(1, YMTDateUtil.YMDTHMS_STRING);
            activityStockBean.setEndTime(EndTime);
            activityStockBean.setActivityType(2);//1:普通 2：预售
          
            activityStockBean.getFBXCatalogLockList().get(0).setEarnest(10);//定金（预售活动必填）
            activityStockBean.getFBXCatalogLockList().get(0).setEarnestDedution(15);//定金立减（预售活动必填）
            activityStockBean.getFBXCatalogLockList().get(0).setAction(1);//是否删除 -1 删除，0 正常，缴了保证金 1预售,未缴保证金
            
            activityStockBean.getFBXCatalogLockList().get(1).setEarnest(20);//定金（预售活动必填）
            activityStockBean.getFBXCatalogLockList().get(1).setEarnestDedution(25);//定金立减（预售活动必填）
            activityStockBean.getFBXCatalogLockList().get(1).setAction(1);//是否删除 -1 删除，0 正常，缴了保证金 1预售,未缴保证金
            
            ProdStockCallService.AuditProductActivityStock(activityStockBean);
            
			String productId=activityStockBean.getProductID();
			//修改Ymt_ProductActivityStock 表的 Action=0 缴了保证金
			ymtProductActivityStockWapper.updateiActionByActivityIdAndProductId(0, productId,activityStockBean.getActivityID());

			
			String startTime = YMTDateUtil.getBeforeOrNextDayStr(YMTDateUtil.getBeforeOrNextDay(0), 0);
			String productName="修改报名活动名称指令测试_"+startTime;
			new YmtActivityWapper().updateSaleSideName(activityStockBean.getActivityID(),productName);
			
			YmtProductsInActivity  productsInActivity=productInActivityWapper.selectAllByiActivityId(activityStockBean.getActivityID()).get(0);
			
			Logger.comment("##############productsInActivity.getIproductinactivityid():"+activityStockBean.getProductActivityId());
			bean.setActionType("SyncActivityProduct"); 
			bean.setActivityId(productsInActivity.getIproductinactivityid());
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			call.setData(bean);
			call.callService();
			
			Thread.sleep(5000);
			YmtActivityTemplateWapper ymtActivityTempWapper=new YmtActivityTemplateWapper();
			
			YmtActivity ymtActivity=ymtActivityWapper.getRecordByActivityId(activityStockBean.getActivityID());
			YmtActivityTemplate temp=ymtActivityTempWapper.selectActivityTemplateById(ymtActivity.getIactivitytemplateid());
			List<YmtProductActivityStock> ymtproductActivityStock=ymtProductActivityStockWapper.selectByProductId(productId);
			// 验证mongo
		    Map<String,Object> p= activityProductsWapper.getByProdId(productId);
			Logger.verifyEquals(p.get("aname").toString(), productName, "验证mongo 表 activityProducts 返回的活动名称");
			Logger.verifyEquals(p.get("alevel").toString(), temp.getActivityLevel().toString(),"验证mongo 表 alevel ");
			JSONArray cObjArray =new JSONArray(p.get("catalogs").toString());
			for(int i=0;i<ymtproductActivityStock.size();i++)
			{
				for(int j=0;j<cObjArray.length();j++)
				{
					if(ymtproductActivityStock.get(i).getScatalogid().equals(new JSONObject(cObjArray.get(j).toString()).get("cid")))
					{
						Logger.verifyEquals(new BigDecimal(new JSONObject(cObjArray.get(i).toString()).get("earnest").toString()).stripTrailingZeros(),
								new BigDecimal(ymtproductActivityStock.get(i).getEarnest()).stripTrailingZeros(),"验证mongo表第"+i+"个规格上的earnest");
					}
				}
			}
			Logger.verifyEquals(new JSONObject(new JSONArray(p.get("catalogs").toString()).get(0).toString()).get("atype"), 2,"验证mongo表第1个规格上的atype");
			Logger.verifyEquals(new JSONObject(new JSONArray(p.get("catalogs").toString()).get(1).toString()).get("atype"), 2,"验证mongo表第1个规格上的atype");
			
			Logger.verifyEquals(p.get("earnest"), 10.0,"验证mongo表最外层earnest ");
			Logger.verifyEquals(p.get("ededution"), 15.0,"验证mongo表最外层ededution ");
			
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间");
			Logger.verifyNotNull(ob.get("aut"), "验证aut活动商品更新时间不为空");
			
			
			Map<String,Object> map7 = productTimeStampWapper.getByProductId(productId);	
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		    long cut_mongo=sdf.parse(sdf.format(map7.get("cut"))).getTime();
		    long sut_mongo=sdf.parse(sdf.format(map7.get("sut"))).getTime();
		    long aut_mongo=sdf.parse(sdf.format(map7.get("aut"))).getTime();

			Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");
			Logger.verifyEquals((long)ob.get("aut"),aut_mongo, "验证redis aut规格更新时间与mongo一致");
					
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
		
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_028() {
		Logger.start(true,"同步mongo-验证指令SyncActivityProduct,如果是预售商品，未缴纳保证金则不同步");
		try{
            AuditProductActivityStockBean activityStockBean = ProdStockCallService.initAuditProductActivityStockBean(sellerId);
            String BeginTime = YMTDateUtil.getBeforeOrNextHour(-1, YMTDateUtil.YMDTHMS_STRING);
            activityStockBean.setBeginTime(BeginTime);
            String EndTime = YMTDateUtil.getBeforeOrNextHour(1, YMTDateUtil.YMDTHMS_STRING);
            activityStockBean.setEndTime(EndTime);
            activityStockBean.setActivityType(2);//1:普通 2：预售
          
            activityStockBean.getFBXCatalogLockList().get(0).setEarnest(10);//定金（预售活动必填）
            activityStockBean.getFBXCatalogLockList().get(0).setEarnestDedution(15);//定金立减（预售活动必填）
            activityStockBean.getFBXCatalogLockList().get(0).setAction(1);//是否删除 -1 删除，0 正常，缴了保证金 ，1：预售,缴保证金
            
            activityStockBean.getFBXCatalogLockList().get(1).setEarnest(20);//定金（预售活动必填）
            activityStockBean.getFBXCatalogLockList().get(1).setEarnestDedution(25);//定金立减（预售活动必填）
            activityStockBean.getFBXCatalogLockList().get(1).setAction(1);//是否删除 -1 删除，0 正常，缴了保证金 ，1：预售,缴保证金
            
            ProdStockCallService.AuditProductActivityStock(activityStockBean);
			String productId=activityStockBean.getProductID();
			//修改Ymt_ProductActivityStock 表的 Action=0 缴了保证金
		//	ymtProductActivityStockWapper.updateiActionByActivityIdAndProductId(0, productId,activityStockBean.getActivityID());

			String startTime = YMTDateUtil.getBeforeOrNextDayStr(YMTDateUtil.getBeforeOrNextDay(0), 0);
			String productName="修改报名活动名称指令测试_"+startTime;
			new YmtActivityWapper().updateSaleSideName(activityStockBean.getActivityID(),productName);
			
			YmtProductsInActivity  productsInActivity=productInActivityWapper.selectAllByiActivityId(activityStockBean.getActivityID()).get(0);
			Logger.comment("##############productsInActivity.getIproductinactivityid():"+activityStockBean.getProductActivityId());
			bean.setActionType("SyncActivityProduct"); 
			bean.setActivityId(productsInActivity.getIproductinactivityid());
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			call.setData(bean);
			call.callService(); 
			
			Thread.sleep(5000);
			
			JSONObject obj=new  JSONObject(call.getReturnData());
			Logger.verifyEquals(true,obj.get("errorMessage").toString().contains("getActivityProductCatalogs 为空"), "验证errorMessage");
			Logger.verifyEquals("-3",obj.get("errorCode").toString(), "验证errorCode");
			Logger.verifyEquals("false",obj.get("success").toString(), "验证success");
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_028_1() {
		Logger.start(true,"同步mongo-验证指令SyncActivityProduct,同步活动商品,重点验证若市场价market=\"\"则设置为\"0\" (20201202排查-排除活动审核有问题)");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			//同步商品
			this.createProduct_sync(productId);
			//获取规格ID
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			//去掉规格列表的第一个参数
			//String catalog0 = catalogs.remove(0);
			//创建一个活动  得到活动id
			Integer activityId = ProductManagerCallServiceV2.createIsolationActivityInProcess();
			
			//报名活动  获得商品在活动中的id
			List<String> aids = ProductManagerCallServiceV2.ApplyActivity(productId, sellerId,catalogs,activityId, 100,"10");
			
			//审核通过
			ProductManagerCallServiceV2.approveProductInActivity(productId,aids.get(0),true);
			
			YmtProductsInActivity  productsInActivity=productInActivityWapper.selectAllByiActivityId(activityId).get(0);
			productsInActivity.setSmarketprice("");//修改市场价为空
			productInActivityWapper.updateByPrimaryKey(productsInActivity);
			
			Thread.sleep(5000);
			bean.setActionType("SyncActivityProduct");
			bean.setActivityId(productsInActivity.getIproductinactivityid());
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();
			YmtActivityTemplateWapper ymtActivityTempWapper=new YmtActivityTemplateWapper();
			
			YmtActivity ymtActivity=ymtActivityWapper.getRecordByActivityId(activityId);
			YmtActivityTemplate temp=ymtActivityTempWapper.selectActivityTemplateById(ymtActivity.getIactivitytemplateid());
			// 验证mongo
		    Map<String,Object> p= activityProductsWapper.getByProdId(productId);
			Logger.verifyEquals(p.get("market").toString(), "0","验证mongo 表 market ");//市场价
			
		
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	

	@Test
	@Category({P1.class}) 
	@TestCase
	public void Tc_Mongocrud_029() {
		Logger.start(true,"同步mongo-验证指令CreateGroupon,创建商品拼团");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId3);
//			addpro.getProduct().getCatalogList().get(0).setPrice(100);
//			addpro.getProduct().getCatalogList().get(1).setPrice(100);
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			//创建预售 平团价格  fMarketPrice 码头市场价格，max（规格码头市场价*90%，规格码头市场价-10元）   等出来的指要小于 fQuotePrice
			Double price0=addpro.getProduct().getCatalogList().get(0).getPrice();
			Double price1=addpro.getProduct().getCatalogList().get(1).getPrice();
			Double fprice0=price0 * 0.9d>price0 -10?price0 * 0.9d:price0 -10;
			Double fprice1=price1 * 0.9d>price1 -10?price1 * 0.9d:price1 -10;	
			SaveGrouponBean saveGrouponBean=ProductManagerCallServiceV3.initSaveGrouponBean(sellerId3,productId,fprice0>fprice1?fprice1-1:fprice0-1);
			
			ProductManagerCallServiceV3.SaveGrouponCall(saveGrouponBean);
			
			List<GrouponProducts> gp = YmtProductsIWapper.selectGrouponProducts(saveGrouponBean.getProductId(), null, 0);
			
			bean.setActionType("CreateGroupon"); 
			bean.setActivityId(gp.get(0).getGrouponProductId());
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			bean.setExtParam(gp.get(0).getVersion().toString());
			call.setData(bean);
			call.callService();
			//验证mongDB表 GrouponProducts
			Map<String,Object>  map=mongoDB_grouponProductsWapper.getByProductId(productId);
			
			List<GrouponCatalogs> catalogs = YmtProductsIWapper.selectGrouponCatalogs(null, gp.get(0).getVersion().intValue());
			JSONArray jsonArray=new JSONArray(map.get("catalogs").toString());
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
			Logger.verifyEquals(Long.parseLong(map.get("ver").toString()),gp.get(0).getVersion(), "验证mongo ver字段与sql数据库Version字段一致");
			Logger.verifyEquals(Integer.parseInt(map.get("goId").toString()),gp.get(0).getGrouponProductId(), "验证mongo goId字段与sql数据库GrouponProductId字段一致");
			//Logger.verifyEquals(sdf.format(map.get("start")),sdf.format(gp.get(0).getStartTime()), "验证mongo start字段与sql数据库StartTime字段一致");
			//Logger.verifyEquals(sdf.format(map.get("end")),sdf.format(gp.get(0).getEndTime()), "验证mongo end字段与sql数据库EndTime字段一致");
			//Logger.verifyEquals(sdf.format(map.get("updatetime")),sdf.format(gp.get(0).getUpdateTime()), "验证mongo updatetime字段与sql数据库UpdateTime字段一致");
			Logger.verifyEquals(new JSONArray(map.get("catalogs").toString()).length(),catalogs.size(), "验证mongo 数据与与sql数据库 一致");

			for(int i=0;i<catalogs.size();i++)
			{
				for(int j=0;j<jsonArray.length();j++)
				{
					if(catalogs.get(i).getCatalogId().equals(new JSONObject(jsonArray.get(j).toString()).get("cid")))
					{
						Logger.verifyEquals(catalogs.get(i).getCatalogId(),new JSONObject(jsonArray.get(j).toString()).get("cid"), 
								"验证mongo cid字段与数据库GrouponProducts表 catalogs字段一致");
						Logger.verifyEquals(catalogs.get(i).getGrouponPrice().stripTrailingZeros().toString(),
								new BigDecimal(new JSONObject(jsonArray.get(j).toString()).get("price").toString()).stripTrailingZeros().toString(), 
								"验证mongo cid字段与数据库GrouponProducts表 catalogs字段一致");
						 break;
					}
				}
			}
			//验证redis与mongDB
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Map<String,Object> map2 = productTimeStampWapper.getByProductId(productId);	
		    long gut_mongo=sdf.parse(sdf.format(map2.get("gut"))).getTime();
			//Logger.verifyEquals((long)ob.get("gut"),gut_mongo, "验证redis gut拼团创建时间与mongo一致");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class}) 
	@TestCase
	public void Tc_Mongocrud_029_5() {
		Logger.start(true,"同步mongo-验证指令CreateGroupon,创建商品拼团");
		try{
//			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId3);
//			addpro.getProduct().getCatalogList().remove(0);
////			addpro.getProduct().getCatalogList().get(0).setPrice(100);
////			addpro.getProduct().getCatalogList().get(1).setPrice(100);
//			//获取商品ID
//			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			String productId="p4168878";
			//创建预售 平团价格  fMarketPrice 码头市场价格，max（规格码头市场价*90%，规格码头市场价-10元）   等出来的指要小于 fQuotePrice
//			Double price0=addpro.getProduct().getCatalogList().get(0).getPrice();
//			Double price1=addpro.getProduct().getCatalogList().get(1).getPrice();
//			Double fprice0=price0 * 0.9d>price0 -10?price0 * 0.9d:price0 -10;
//			Double fprice1=price1 * 0.9d>price1 -10?price1 * 0.9d:price1 -10;	
			//SaveGrouponBean saveGrouponBean=ProductManagerCallServiceV3.initSaveGrouponBean(sellerId3,productId,fprice0>fprice1?fprice1-1:fprice0-1);
			SaveGrouponBean saveGrouponBean=ProductManagerCallServiceV3.initSaveGrouponBean(sellerId3,productId,13d);
			
			ProductManagerCallServiceV3.SaveGrouponCall(saveGrouponBean);
			
			List<GrouponProducts> gp = YmtProductsIWapper.selectGrouponProducts(saveGrouponBean.getProductId(), null, 0);
			
			bean.setActionType("CreateGroupon"); 
			bean.setActivityId(gp.get(0).getGrouponProductId());
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			bean.setExtParam(gp.get(0).getVersion().toString());
			call.setData(bean);
			call.callService();
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	

	
	
	

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_030() {
		Logger.start(true,"同步mongo-验证指令ModifyGrouponPrice,修改商品规格并团价");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId3);
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			//创建预售
			addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId3);
			//创建预售 平团价格  fMarketPrice 码头市场价格，max（规格码头市场价*90%，规格码头市场价-10元）   等出来的指要小于 fQuotePrice
			Double price0=addpro.getProduct().getCatalogList().get(0).getPrice();
			Double price1=addpro.getProduct().getCatalogList().get(1).getPrice();
			Double fprice0=price0 * 0.9d>price0 -10?price0 * 0.9d:price0 -10;
			Double fprice1=price1 * 0.9d>price1 -10?price1 * 0.9d:price1 -10;	
			SaveGrouponBean saveGrouponBean=ProductManagerCallServiceV3.initSaveGrouponBean(sellerId3,productId,fprice0>fprice1?fprice1-1:fprice0-1);
			
			ProductManagerCallServiceV3.SaveGrouponCall(saveGrouponBean);

			Double update_grouponPrice=price0-2;
			List<GrouponProducts> gp = YmtProductsIWapper.selectGrouponProducts(saveGrouponBean.getProductId(), null, 0);
			saveGrouponBean=ProductManagerCallServiceV3.initSaveGrouponBean(sellerId3,productId,update_grouponPrice);
			saveGrouponBean.setOperateType(1);//1:编辑 0:创建
			saveGrouponBean.setGrouponProductId(gp.get(0).getGrouponProductId());
			ProductManagerCallServiceV3.SaveGrouponCall(saveGrouponBean);

			bean.setActionType("ModifyGrouponPrice"); 
			bean.setActivityId(gp.get(0).getGrouponProductId());
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			bean.setExtParam(gp.get(0).getVersion().toString());
			call.setData(bean);
			call.callService();
			Thread.sleep(3000);
			//验证mongDB表 GrouponProducts
			Thread.sleep(2000);
			List<GrouponProducts> gp2 = YmtProductsIWapper.selectGrouponProducts(saveGrouponBean.getProductId(), null, 0);
			Map<String,Object>  map=mongoDB_grouponProductsWapper.getByVersion(gp2.get(0).getVersion());
			
			List<GrouponCatalogs> catalogs = YmtProductsIWapper.selectGrouponCatalogs(null, gp2.get(0).getVersion().intValue());
			JSONArray jsonArray=new JSONArray(map.get("catalogs").toString());
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
			Logger.verifyEquals(Long.parseLong(map.get("ver").toString()),gp2.get(0).getVersion(), "验证mongo ver字段与sql数据库Version字段一致");
			Logger.verifyEquals(Integer.parseInt(map.get("goId").toString()),gp2.get(0).getGrouponProductId(), "验证mongo goId字段与sql数据库GrouponProductId字段一致");
			//Logger.verifyEquals(sdf.format(map.get("start")),sdf.format(gp2.get(0).getStartTime()), "验证mongo start字段与sql数据库StartTime字段一致");
			//Logger.verifyEquals(sdf.format(map.get("end")),sdf.format(gp2.get(0).getEndTime()), "验证mongo end字段与sql数据库EndTime字段一致");
			//Logger.verifyEquals(sdf.format(map.get("updatetime")),sdf.format(gp2.get(0).getUpdateTime()), "验证mongo updatetime字段与sql数据库UpdateTime字段一致");
			Logger.verifyEquals(new JSONArray(map.get("catalogs").toString()).length(),catalogs.size(), "验证mongo 数据与与sql数据库 一致");

			for(int i=0;i<catalogs.size();i++)
			{
				for(int j=0;j<jsonArray.length();j++)
				{
					if(catalogs.get(i).getCatalogId().equals(new JSONObject(jsonArray.get(j).toString()).get("cid")))
					{
						Logger.verifyEquals(catalogs.get(i).getCatalogId(),new JSONObject(jsonArray.get(j).toString()).get("cid"), 
								"验证mongo cid字段与数据库GrouponProducts表 catalogs字段一致");
						Logger.verifyEquals(new BigDecimal(update_grouponPrice).stripTrailingZeros().toString(),
								new BigDecimal(new JSONObject(jsonArray.get(j).toString()).get("price").toString()).stripTrailingZeros().toString(), 
								"验证mongo cid字段与数据库GrouponProducts表 catalogs字段一致");
						 break;
					}
				}
			}
			//验证redis与mongDB
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Map<String,Object> map2 = productTimeStampWapper.getByProductId(productId);	
		    long gut_mongo=sdf.parse(sdf.format(map2.get("gut"))).getTime();
			Logger.verifyEquals((long)ob.get("gut"),gut_mongo, "验证redis gut拼团创建时间与mongo一致");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_031() {
		Logger.start(true,"同步mongo-验证指令StopGroupon,停止拼团");
		try{
			
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId3);
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			
			//创建预售 平团价格  fMarketPrice 码头市场价格，max（规格码头市场价*90%，规格码头市场价-10元）   等出来的指要小于 fQuotePrice
			Double price0=addpro.getProduct().getCatalogList().get(0).getPrice();
			Double price1=addpro.getProduct().getCatalogList().get(1).getPrice();
			Double fprice0=price0 * 0.9d>price0 -10?price0 * 0.9d:price0 -10;
			Double fprice1=price1 * 0.9d>price1 -10?price1 * 0.9d:price1 -10;	
			SaveGrouponBean saveGrouponBean=ProductManagerCallServiceV3.initSaveGrouponBean(sellerId3,productId,fprice0>fprice1?fprice1-1:fprice0-1);
			
			ProductManagerCallServiceV3.SaveGrouponCall(saveGrouponBean);
			List<GrouponProducts> gp = YmtProductsIWapper.selectGrouponProducts(saveGrouponBean.getProductId(), null, 0);
			YmtProductsIWapper.updateStatusGrouponProducts(productId,gp.get(0).getVersion(),1,null,null);
			
			bean.setActionType("StopGroupon"); 
			bean.setActivityId(gp.get(0).getGrouponProductId());
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			bean.setExtParam(gp.get(0).getVersion().toString());
			call.setData(bean);
			call.callService();
			Thread.sleep(5000);
			//验证mongDB表 GrouponProducts
			Map<String,Object>   mongoDB_product=mongoDB_productsWapper.getByProductId(productId);
			List<String>  mongoDB_Catalogs=mongoDB_productsWapper.getByPid(productId);

			Logger.verifyEquals("0",mongoDB_product.get("goversion").toString(), "验证mongo goversion字段停止拼团为0");
			for(int i=0;i<mongoDB_Catalogs.size();i++)
			{
				Logger.verifyEquals("null",new JSONObject(mongoDB_Catalogs.get(i)).getString("goprice"), 
						"验证mongo catalogs表 goprice字段停止拼团是为null");
			}
			//验证redis与mongDB
			ImRedisWapper imRedisWapper=new ImRedisWapper();
			JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
			Map<String,Object> map2 = productTimeStampWapper.getByProductId(productId);	
		    long gut_mongo=sdf.parse(sdf.format(map2.get("gut"))).getTime();
			Logger.verifyEquals((long)ob.get("gut"),gut_mongo, "验证redis gut拼团创建时间与mongo一致");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	

	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	//20190816 佣金变更为比例模式此case废弃
	public void Tc_Mongocrud_047() {
		Logger.start(true,"同步mongo-验证指令ChangeCatalogCommission,变更规格佣金-优选团");
		try{
			//发布一个活动商品		
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(globalSellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.verifyNotNull(productId, "响应报文-商品ID");
			//Thread.sleep(5000);
			
			//更改礼包类型
			//请求参数增加字段：giftType: 礼包类型，1礼包商品，2优选团商品
			ProductManagerCallServiceV2.AddSellerGlobalPspProduct(globalSellerId, productId, 2);
			//Thread.sleep(5000);
			
			//查找规格
			YmtCatalogs catalogs=catalogdWapper.selectBySproductId(productId);
			List<BigDecimal> saleCommissionLis=new ArrayList();
			saleCommissionLis.add(new BigDecimal(1.111));
			saleCommissionLis.add(new BigDecimal(2.126));
			saleCommissionLis.add(new BigDecimal(3));
			saleCommissionLis.add(new BigDecimal(4));
			ProductManagerCallServiceV2.UpdateCatalogCommisionsV2(globalSellerId, productId, 
					catalogs.getScatalogid(), globalSellerName, saleCommissionLis);
			Thread.sleep(5000);
			
			bean.setActionType("ChangeCatalogCommission");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();
			Thread.sleep(5000);
			
		    //验证商品编号spid
		    Map<String,Object> p= mongoDB_productsWapper.getByProductId(productId);
			Logger.verifyEquals(p.get("spid").toString(), productId, "验证返回spid");
			//ptype=2是全球优选 gtype=1 是大礼包
            Logger.verifyEquals(2,Integer.parseInt(p.get("ptype").toString()),
            		"验证传入的商品类型ptype与mongo是否一致");
            
            YmtProducts product=productMapper.selectProductByProductId(productId);
			List<YmtCatalogsI> catalogsList = CIWapper.selectCatalogsByProductId(productId);
			
			//规格市场价
			List<String> catelogList= mongoDB_productsWapper.getByPid(productId);
			List<YmtCatalogs> catelogList_sql=new YmtCatalogsWapper().selectCatalogs(productId);
			Logger.verifyEquals(addpro.getProduct().getCatalogList().size(),catelogList.size(),"验证传入的规格 与mongo一致");
			for(int i=0;i<catelogList.size();i++)
			{
				Logger.comment("######################验证commissions######################");
				JSONObject  act=new JSONObject(catelogList.get(i).toString());
				String str_catalogId=act.getString("cid");
				List<YmtCatalogs> exp=catelogList_sql.stream()
					.filter(c->c.getScatalogid().equals(str_catalogId)).collect(Collectors.toList());
				
				if(catalogs.getScatalogid().equals(str_catalogId))
				{
				      Logger.verifyEquals(true,act.getString("commissions").equals(exp.get(0).getSaleCommissions()), "验证第"+i+"条传入的市场价commissions与mongo数据库是否一致");
				}
			}	
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	

	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_048() {
		Logger.start(true,"同步mongo-验证指令SetMemberProduct,设置/取消  优选会员商品-设置");
		try{
			//发布一个活动商品		
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(globalSellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.verifyNotNull(productId, "响应报文-商品ID");
			//Thread.sleep(5000);
			
			ProductManagerCallServiceV3.SetMemberProduct(productId, globalSellerId, true);
			
			Thread.sleep(5000);
			
			bean.setActionType("SetMemberProduct");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();
			Thread.sleep(5000);
			
		    //验证商品编号spid
		    Map<String,Object> p= mongoDB_productsWapper.getByProductId(productId);
			Logger.verifyEquals(p.get("spid").toString(), productId, "验证返回spid");
			//ptype=2是全球优选 gtype=1 是大礼包
            Logger.verifyEquals(2,Integer.parseInt(p.get("ptype").toString()),
            		"验证传入的商品类型ptype与mongo是否一致");

            Logger.verifyEquals(true,(boolean)p.get("member"),
            		"验证传入的商品类型member与mongo是否一致");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_048_1() {
		Logger.start(true,"同步mongo-验证指令SetMemberProduct,设置/取消  优选会员商品-取消");
		try{
			//发布一个活动商品		
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(globalSellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.verifyNotNull(productId, "响应报文-商品ID");
			//Thread.sleep(5000);
			
			ProductManagerCallServiceV3.SetMemberProduct(productId, globalSellerId, false);
			
			Thread.sleep(5000);
			
			bean.setActionType("SetMemberProduct");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean);
			call.callService();
			Thread.sleep(5000);
			
		    //验证商品编号spid
		    Map<String,Object> p= mongoDB_productsWapper.getByProductId(productId);
			Logger.verifyEquals(p.get("spid").toString(), productId, "验证返回spid");
			//ptype=2是全球优选 gtype=1 是大礼包
            Logger.verifyEquals(2,Integer.parseInt(p.get("ptype").toString()),
            		"验证传入的商品类型ptype与mongo是否一致");

            Logger.verifyEquals(false,(boolean)p.get("member"),
            		"验证传入的商品类型member与mongo是否一致");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}

	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_053() {
		Logger.start(true,"同步mongo-验证指令SyncAlhProduct,同步安利会-没有设置费率(使用sql配置表的费率 Ymt_AnlihuiRebateConfig)");
		try{
			//发布一个商品		
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			addpro.getProduct().setProductType(3);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.verifyNotNull(productId, "响应报文-商品ID");
			ProductManagerCallServiceV3.BatchAddAlhProduct(addpro.getSellerId(),productId);
			
			bean.setActionType("SyncAlhProduct");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean); 
			call.callService();
			YmtAnlihuiProductWrapper anlihuiProductWapper=new YmtAnlihuiProductWrapper();
			YmtAnlihuiProduct anlihuiProduct=anlihuiProductWapper.selectByProductId(productId);
//			YmtAnlihuiRebateConfigWrapper configWapper=new YmtAnlihuiRebateConfigWrapper();
//			configWapper.selectBySecondCategoryId();
		    //验证商品
		    Map<String,Object> p= mongoDB_productsWapper.getByProductId(productId);
			Logger.verifyEquals(anlihuiProduct.getId(),Integer.parseInt(p.get("alhid").toString()), "验证返回alhid");
            Logger.verifyEquals(anlihuiProduct.getPlatformRebateRate().stripTrailingZeros().toPlainString()
            		,new BigDecimal(p.get("alhprebate").toString()).stripTrailingZeros().toPlainString(), "验证传入的商品类型alhprebate与mongo数据库是否一致");
            Logger.verifyEquals(anlihuiProduct.getRebateRate().stripTrailingZeros().toPlainString(),new BigDecimal(p.get("alhsrebate").toString()).stripTrailingZeros().toPlainString(), "验证传入的商品类型alhsrebate与mongo数据库是否一致");
		
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_053_1() {
		Logger.start(true,"同步mongo-验证指令SyncAlhProduct,同步安利会-设置费率");
		try{
			//发布一个商品		
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			addpro.getProduct().setProductType(3);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.verifyNotNull(productId, "响应报文-商品ID");
			ProductManagerCallServiceV3.BatchAddAlhProduct(addpro.getSellerId(),productId);
			//设置安利会费率
			ProductManagerCallServiceV3.SetAlhProductRebateRate(addpro.getSellerId(), productId, new BigDecimal("0.3"));
			
			bean.setActionType("SyncAlhProduct");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean); 
			call.callService();
			YmtAnlihuiProductWrapper anlihuiProductWapper=new YmtAnlihuiProductWrapper();
			YmtAnlihuiProduct anlihuiProduct=anlihuiProductWapper.selectByProductId(productId);
			
		    //验证商品编号spid
		    Map<String,Object> p= mongoDB_productsWapper.getByProductId(productId);
			Logger.verifyEquals(anlihuiProduct.getId().toString(),p.get("alhid").toString(), "验证返回alhid");
            Logger.verifyEquals(anlihuiProduct.getRebateRate().stripTrailingZeros().toString()
            		,new BigDecimal(p.get("alhsrebate").toString()).stripTrailingZeros().toString(), "验证传入的商品类型alhsrebate与mongo数据库是否一致");
            Logger.verifyEquals(anlihuiProduct.getPlatformRebateRate().stripTrailingZeros().toString()
            		,new BigDecimal(p.get("alhprebate").toString()).stripTrailingZeros().toString(), "验证传入的商品类型alhprebate与mongo数据库是否一致");
		
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	

	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Mongocrud_058() {
		Logger.start(true,"同步mongo-验证指令UpdateAuditStatus,审核状态");
		try{	
			//发布一个商品		
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			addpro.getProduct().setProductType(3);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.verifyNotNull(productId, "响应报文-商品ID");
			//修改审核状态
			ProductManagerCallServiceV3.UpdateAuditStatus(productId, 1);
			
			bean.setActionType("UpdateAuditStatus");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			call.setData(bean); 
			call.callService();
			
		    //验证商品审核状态
		    Map<String,Object> p= mongoDB_productsWapper.getByProductId(productId);
			Logger.verifyEquals(p.get("as").toString(), "1", "验证返回审核状态");
    		
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	

	
	
	private void checkverify_godProduct(Map<String,Object> p,String productId,AddAgentProductBean addAgentProductBean) throws Exception
	{
		//ymt_product 与 mongo_product 比较
        Map<String,Object> pmap = ipm.selectProductByProdId(productId);
        YmtProductsI YmtProductsI=YmtProductsIWapper.selectProductByProductId(productId).get(0);
        Logger.verifyEquals(Integer.parseInt(pmap.get("CardInfo").toString()),Integer.parseInt(p.get("card").toString()), "验证传入的商品类型card与mongo数据库是否一致");
        Logger.verifyEquals(Integer.parseInt(pmap.get("iCatalogStatus").toString()),Integer.parseInt(p.get("deliv").toString()), "验证传入的商品类型RootProductId与mongo数据库是否一致");
      
       //ymt_AgentProducts  与 mongo_product 比较
        AgentProductPo agentProductPo= YmtProductsIWapper.selectAgentProductByProductId(productId);
        Logger.verifyEquals(agentProductPo.getInfoProgress(),Integer.parseInt(p.get("infop").toString()), "验证传入的商品类型infop与mongo数据库是否一致");
        Logger.verifyEquals(agentProductPo.getAgentChain(),p.get("achain").toString(), "验证传入的代理关系achain与mongo数据库是否一致");
        Logger.verifyEquals(agentProductPo.getCurrency(),p.get("currency").toString(), "验证currency与mongo数据库是否一致");
        //是否是自提
        Logger.verifyEquals(agentProductPo.getCollectionGoods(),(boolean)p.get("colgoods"), "验证collectionGoods与mongo数据库是否一致");
        //快递配送
        Logger.verifyEquals(agentProductPo.getExpressDelivery(),(boolean)p.get("expdel"), "验证expressDelivery与mongo数据库是否一致");
        //最小起购数量
        Logger.verifyEquals(agentProductPo.getMinOrderNum(),Integer.parseInt(p.get("moq").toString()), "验证MinOrderNum与mongo数据库是否一致");
        
        Logger.comment(" ####currency:#### "+p.get("currency"));
        //Ymt_Catalogs  与 mongo_product 比较
        Logger.debug("验证规格");
     
        List<YmtCatalogsI> ymtCatalogsIList = CIWapper.selectCatalogsByProductId(productId);
        addAgentProductBean.getCatalogList().forEach(c->{
            
            for (YmtCatalogsI ymtCatalogsI:ymtCatalogsIList) {
            	 if (c.getSku().equals(ymtCatalogsI.getsSKU()) && new BigDecimal(c.getDirectPrice()).stripTrailingZeros().equals(ymtCatalogsI.getfQuotePrice().stripTrailingZeros()) ){
            		 
                     try {
                    	Logger.comment("##########sku:"+c.getSku()+"###########");
                    	BasicDBObject search = new BasicDBObject();
         				search.append("sku", c.getSku());
         				search.append("spid", productId);
         				search.append("price", c.getDirectPrice());
         				
         				// 验证规格相关
         				List<Map> clist = mongoDB_productsWapper.selectCatalogs(search, null);
						Logger.verifyEquals(ymtCatalogsI.getParentCatalogId(),clist.get(0).get("pcid")==null?null:clist.get(0).get("pcid").toString(),"验证pcid 上级规格id");
                        Logger.verifyEquals(ymtCatalogsI.getRootCatalogId(),clist.get(0).get("rcid").toString(),"验证rcid 渠道原始规格Id");
                        Logger.verifyEquals(ymtCatalogsI.getfQuotePrice().stripTrailingZeros().toString(),new BigDecimal(clist.get(0).get("price").toString()).stripTrailingZeros().toString(),"验证price 渠道原始规格QuotePrice");
                        Logger.verifyEquals(ymtCatalogsI.getsPicUrl(),clist.get(0).get("catapic").toString(),"验证规格price");
                        
                        
                        //若是自采商品，stock=实际库存;若是代理，stock=0
                        int stock=Integer.parseInt(p.get("agtype").toString())==0?c.getStock():0;
                        Logger.verifyEquals(stock,Integer.parseInt(clist.get(0).get("stock").toString()),"验证库存stock 库存 ");

                        Logger.verifyEquals(c.getMarketAmount(), Double.parseDouble(clist.get(0).get("marketamt").toString()), "验证规格市场价marketamt");//神器市场价 新增 20200325
                        //
                        
					} catch (Exception e) {
						e.printStackTrace();
					}  
             }
           }
        }); 
	}
	/**
	 * 验证渠道商品是否售完
	 * @param productId
	 * @throws Exception
	 */
	private void check_godMainProduct_issellout(String productId,String... agentProductId) throws Exception
	{
		 //验证是否渠道售完
        int inum=0;//规格上的库存
        BasicDBObject search = new BasicDBObject();
		search.append("spid", productId);
		List<Map> clist =mongoDB_productsWapper.selectCatalogs(search, null);
		for(int i=0;i<clist.size();i++)
		{
			inum = Integer.parseInt(clist.get(i).get("stock").toString());
		}
		Map<String,Object> p1= mongoDB_productsWapper.getByProductId(productId);

        Logger.verifyEquals(inum==0?true:false,(boolean)p1.get("issellout"),"验证monogo 商品表是否售完字段 issellout ");
        if(agentProductId.length>0){
			Map<String,Object> p2= mongoDB_productsWapper.getByProductId(agentProductId[0]);
	        Logger.verifyEquals(inum==0?true:false,(boolean)p2.get("issellout"),"验证monogo 商品表是否售完字段 issellout ");
        }
        
        //验证非境内商品
        Logger.verifyEquals(p1.get("domestic").toString(), Integer.parseInt(p1.get("ruid").toString())==this.domestic_sellerId?"true":"false", "验证productDescExtra表中的domestic字段");
        
	}
	/**
	 * 创建商品
	 * @param productId
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	private void createProduct_sync(String productId) throws ClientProtocolException, IOException
	{
		bean.setActionType("CreateProduct");
		bean.setActivityId(0);
		bean.setProductId(productId);
		bean.setTransactionId(TestDataManager.getRandomIntNum(9));
		call.setData(bean);
		call.callService();
	}
	/**
	 * 创建自采商品
                 导入代理商品
	 * @param productId
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	 private void AddAgentProduct_sync(String productId) throws ClientProtocolException, IOException
	 {
			bean.setActionType("AddAgentProduct");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));
			call.setData(bean);
			call.callService();
	 }
	 
	 private void AddproductSearch(String productId,AddAgentProductBean addAgentProductBean,List<Map> clist) throws JSONException, ClientProtocolException, IOException{
		//查询商品
         GetProductInfoByProductIdBean pbean=new GetProductInfoByProductIdBean();
         GetProductInfoByProductIdCall pCall=new GetProductInfoByProductIdCall();
         pbean.setProductId(productId);
       //  pbean.setNextActivityExpire(1);
         pCall.setData(pbean);
         pCall.callService();
         JSONArray expCatalogArray=new JSONObject(pCall.getReturnData()).getJSONObject("Data").getJSONObject("Product").getJSONArray("CatalogList");
         JSONObject expCurrencyObject=new JSONObject(pCall.getReturnData()).getJSONObject("Data").getJSONObject("Product").getJSONObject("MarketCurrencyExchangeRate");
         JSONObject expProductObject=new JSONObject(pCall.getReturnData()).getJSONObject("Data").getJSONObject("Product");
         
		 Logger.verifyEquals(new JSONObject(expCatalogArray.get(0).toString()).getString("LimitNum"), clist.get(0).get("limitnum").toString(), "验证查询商品中返回limitnum");
		 Logger.verifyEquals(Double.parseDouble(expProductObject.getString("TariffRate")),addAgentProductBean.getTariffRate(), "验证查询商品中返回TariffRate");
			//MarketCurrency
		 Logger.verifyEquals(new JSONObject(expCurrencyObject.toString()).getString("Currency"),addAgentProductBean.getMarketCurrency(), "验证查询商品中返回MarketCurrencyExchangeRate中的MarketCurrency");
	 }
	 
	 private void ModifyproductSearch(String productId,ModifyAgentProductBean addAgentProductBean,List<Map> clist) throws JSONException, ClientProtocolException, IOException{
		//查询商品
         GetProductInfoByProductIdBean pbean=new GetProductInfoByProductIdBean();
         GetProductInfoByProductIdCall pCall=new GetProductInfoByProductIdCall();
         pbean.setProductId(productId);
       //  pbean.setNextActivityExpire(1);
         pCall.setData(pbean);
         pCall.callService();
         JSONArray expCatalogArray=new JSONObject(pCall.getReturnData()).getJSONObject("Data").getJSONObject("Product").getJSONArray("CatalogList");
         JSONObject expCurrencyObject=new JSONObject(pCall.getReturnData()).getJSONObject("Data").getJSONObject("Product").getJSONObject("MarketCurrencyExchangeRate");
         JSONObject expProductObject=new JSONObject(pCall.getReturnData()).getJSONObject("Data").getJSONObject("Product");
         
		 Logger.verifyEquals(new JSONObject(expCatalogArray.get(0).toString()).getString("LimitNum"), clist.get(0).get("limitnum").toString(), "验证查询商品中返回limitnum");
		 Logger.verifyEquals(Double.parseDouble(expProductObject.getString("TariffRate")),addAgentProductBean.getTariffRate(), "验证查询商品中返回TariffRate");
			//MarketCurrency
		 Logger.verifyEquals(new JSONObject(expCurrencyObject.toString()).getString("Currency"),addAgentProductBean.getMarketCurrency(), "验证查询商品中返回MarketCurrencyExchangeRate中的MarketCurrency");
	 }
	 
	 
	   /**
		 * 验证越洋店铺小视频
		 * @param productId
		 * @throws Exception
		 */
		private void check_godVideo(String productId,AddAgentProductBean addAgentProductBean) throws Exception
		{
			 //验证是否渠道售完
			Map<String,Object> p1= mongoDB_productsWapper.getByProductId(productId);
			JSONObject jsonObject=new JSONObject(p1.get("v").toString());
			
		    Logger.verifyEquals(addAgentProductBean.getVideo().getPic(),jsonObject.get("p"),"验证monogo 商品表小视频url");
		    Logger.verifyEquals(addAgentProductBean.getVideo().getHeight(),jsonObject.get("h"),"验证monogo 商品表小视频Height");
		    Logger.verifyEquals(addAgentProductBean.getVideo().getSize(),jsonObject.get("s"),"验证monogo 商品表小视频Size");
		    Logger.verifyEquals(addAgentProductBean.getVideo().getLength(),jsonObject.get("l"),"验证monogo 商品表小视频Length");
		    Logger.verifyEquals(addAgentProductBean.getVideo().getUrl(),jsonObject.get("u"),"验证monogo 商品表小视频Url");
		    Logger.verifyEquals(addAgentProductBean.getVideo().getWidth(),jsonObject.get("w"),"验证monogo 商品表小视频Width");
	        
		}




		//////////////////// 忽略case ///////////////////////////
		@Test
		@Category({P1.class})
		@TestCase
		@Ignore
		public void Tc_Mongocrud_002_2() {
			Logger.start(true,"同步mongo-验证指令CreateProduct,新增商品-大礼包");
			try{
				//发布一个活动商品
				AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(globalSellerId);
				String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
				ProductManagerCallServiceV2.AddSellerGlobalPspProduct(globalSellerId,productId,1);
				//同步商品
				createProduct_sync(productId);
				Logger.verifyNotNull(productId, "响应报文-商品ID");

				bean.setActionType("CreateProduct");
				bean.setActivityId(0);
				bean.setProductId(productId);
				bean.setTransactionId(TestDataManager.getRandomIntNum(9));

				call.setData(bean);
				call.callService();

				//验证商品编号spid
				Map<String,Object> p= mongoDB_productsWapper.getByProductId(productId);
				Logger.verifyEquals(p.get("spid").toString(), productId, "验证返回spid");
				//ptype=2是全球优选 gtype=1 是大礼包
				Logger.verifyEquals(2,Integer.parseInt(p.get("ptype").toString()),
						"验证传入的商品类型ptype与mongo是否一致");
				Logger.verifyEquals(1,Integer.parseInt(p.get("gtype").toString()),
						"验证传入的商品类型gtype与mongo是否一致");

				YmtProducts product=productMapper.selectProductByProductId(productId);
				List<YmtCatalogsI> catalogsList = CIWapper.selectCatalogsByProductId(productId);

				//规格市场价
				List<String> catelogList= mongoDB_productsWapper.getByPid(productId);
				List<YmtCatalogs> catelogList_sql=new YmtCatalogsWapper().selectCatalogs(productId);
				Logger.verifyEquals(addpro.getProduct().getCatalogList().size(),catelogList.size(),"验证传入的规格 与mongo一致");
				for(int i=0;i<catelogList.size();i++)
				{
					Logger.comment("######################验证mprice######################");
					JSONObject  act=new JSONObject(catelogList.get(i).toString());
					String str_catalogId=act.getString("cid");
					List<YmtCatalogs> exp=catelogList_sql.stream()
							.filter(c->c.getScatalogid().equals(str_catalogId)).collect(Collectors.toList());
					Logger.verifyEquals(Double.parseDouble(exp.get(0).getFMarketPrice().toString()),act.getDouble("mprice"), "验证第"+i+"条传入的市场价mprice与mongo数据库是否一致");
				}

				ImRedisWapper imRedisWapper=new ImRedisWapper();
				JSONObject ob=new JSONObject(imRedisWapper.getproductById(productId));
				Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
				Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
				Logger.verifyEquals("null",ob.get("lut").toString(), "验证lut直播商品更新时间");
				Logger.verifyEquals("null",ob.get("aut").toString(), "验证aut活动商品更新时间为空");

				Logger.verifyEquals(true,(long)ob.get("cut")>catalogsList.get(catalogsList.size()-1).getUpdateTime().getTime(), "验证cut规格更新时间");
				Logger.verifyEquals(true,(long)ob.get("sut")>product.getDlastupdate().getTime(), "验证sut商品更新时间");


				Map<String,Object> map2 = new ProductTimeStampWapper().getByProductId(productId);
				// CST(北京时间)在东8区
				sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
				long cut_mongo=sdf.parse(sdf.format(map2.get("cut"))).getTime();
				long sut_mongo=sdf.parse(sdf.format(map2.get("sut"))).getTime();

				Logger.verifyEquals((long)ob.get("cut"),cut_mongo, "验证redis cut规格更新时间与mongo一致");
				Logger.verifyEquals((long)ob.get("sut"),sut_mongo, "验证redis sut规格更新时间与mongo一致");

			}catch(Exception e){
				Logger.fail(e);
			}
		}


	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_Mongocrud_002_1() {
		Logger.start(true, "同步mongo-验证指令CreateProduct,新增商品-全球优选商品");
		try {
			//发布一个活动商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(globalSellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.verifyNotNull(productId, "响应报文-商品ID");

			bean.setActionType("CreateProduct");
			bean.setActivityId(0);
			bean.setProductId(productId);
			bean.setTransactionId(TestDataManager.getRandomIntNum(9));

			call.setData(bean);
			call.callService();

			//验证商品编号spid
			Map<String, Object> p = mongoDB_productsWapper.getByProductId(productId);
			Logger.verifyEquals(p.get("spid").toString(), productId, "验证返回spid");
			//ptype=2是全球优选 gtype=1 是大礼包
			Logger.verifyEquals(2, Integer.parseInt(p.get("ptype").toString()),
					"验证传入的商品类型ptype与mongo是否一致");

			YmtProducts product = productMapper.selectProductByProductId(productId);
			List<YmtCatalogsI> catalogsList = CIWapper.selectCatalogsByProductId(productId);

			//规格市场价
			List<String> catelogList = mongoDB_productsWapper.getByPid(productId);
			List<YmtCatalogs> catelogList_sql = new YmtCatalogsWapper().selectCatalogs(productId);
			Logger.verifyEquals(addpro.getProduct().getCatalogList().size(), catelogList.size(), "验证传入的规格 与mongo一致");
			for (int i = 0; i < catelogList.size(); i++) {
				Logger.comment("######################验证mprice######################");
				JSONObject act = new JSONObject(catelogList.get(i).toString());
				String str_catalogId = act.getString("cid");
				List<YmtCatalogs> exp = catelogList_sql.stream()
						.filter(c -> c.getScatalogid().equals(str_catalogId)).collect(Collectors.toList());
				Logger.verifyEquals(Double.parseDouble(exp.get(0).getFMarketPrice().toString()), act.getDouble("mprice"), "验证第" + i + "条传入的市场价mprice与mongo数据库是否一致");
			}

			ImRedisWapper imRedisWapper = new ImRedisWapper();
			JSONObject ob = new JSONObject(imRedisWapper.getproductById(productId));
			Logger.verifyNotNull(ob.get("cut"), "验证cut规格更新时间不为空");
			Logger.verifyNotNull(ob.get("sut"), "验证sut商品更新时间不为空");
			Logger.verifyEquals("null", ob.get("lut").toString(), "验证lut直播商品更新时间");
			Logger.verifyEquals("null", ob.get("aut").toString(), "验证aut活动商品更新时间为空");

			Logger.verifyEquals(true, (long) ob.get("cut") > catalogsList.get(catalogsList.size() - 1).getUpdateTime().getTime(), "验证cut规格更新时间");
			Logger.verifyEquals(true, (long) ob.get("sut") > product.getDlastupdate().getTime(), "验证sut商品更新时间");


			Map<String, Object> map2 = new ProductTimeStampWapper().getByProductId(productId);
			// CST(北京时间)在东8区
			sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
			long cut_mongo = sdf.parse(sdf.format(map2.get("cut"))).getTime();
			long sut_mongo = sdf.parse(sdf.format(map2.get("sut"))).getTime();

			Logger.verifyEquals((long) ob.get("cut"), cut_mongo, "验证redis cut规格更新时间与mongo一致");
			Logger.verifyEquals((long) ob.get("sut"), sut_mongo, "验证redis sut规格更新时间与mongo一致");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}
